114 lines
2.7 KiB
TypeScript
114 lines
2.7 KiB
TypeScript
// User-related queries
|
|
export const updateUser = {
|
|
name: "updateUser",
|
|
text: "INSERT INTO users (userid,displayName,imageUrl) VALUES ($1,$2,$3)\
|
|
ON CONFLICT (userid) DO UPDATE SET displayName = $2, imageUrl = $3"
|
|
}
|
|
|
|
export const checkBan = {
|
|
name: "checkBan",
|
|
text: "SELECT userid FROM bans WHERE userid = $1"
|
|
}
|
|
|
|
// Streamer-related queries
|
|
export const getStreamerId = {
|
|
name: "getStreamerId",
|
|
text: "SELECT userid FROM streamer"
|
|
}
|
|
|
|
export const getStreamerIdToken = {
|
|
name: "getStreamerIdToken",
|
|
text: "SELECT userid,tokenpair FROM streamer"
|
|
}
|
|
|
|
export const getStreamerInfo = {
|
|
name: "getStreamerInfo",
|
|
text: "SELECT userid,displayname,imageurl FROM streamer_user_vw"
|
|
}
|
|
|
|
export const updateStreamer = {
|
|
name: "updateStreamer",
|
|
text: "INSERT INTO streamer (userid,tokenPair) VALUES ($1,$2)\
|
|
ON CONFLICT (userid) DO UPDATE SET tokenPair = $2"
|
|
}
|
|
|
|
// Request-related queries
|
|
export const getRequests = {
|
|
name: "getRequests",
|
|
text: "SELECT * FROM requests_vw \
|
|
JOIN states ON requests_vw.state = states.state \
|
|
WHERE active LIMIT $1"
|
|
}
|
|
|
|
export const getRequestsVoted = {
|
|
name: "getRequestsVoted",
|
|
text: "SELECT * FROM get_requests_voted($2) \
|
|
JOIN states ON get_requests_voted.state = states.state \
|
|
WHERE active LIMIT $1"
|
|
}
|
|
|
|
export const getAllRequests = {
|
|
name: "getAllRequests",
|
|
text: "SELECT * FROM requests_vw LIMIT $1"
|
|
}
|
|
|
|
export const getAllRequestsVoted = {
|
|
name: "getAllRequestsVoted",
|
|
text: "SELECT * FROM get_requests_voted($2) LIMIT $1"
|
|
}
|
|
|
|
export const checkRequestExists = {
|
|
name: "checkRequestExists",
|
|
text: "SELECT url FROM requests WHERE url = $1"
|
|
}
|
|
|
|
export const addRequest = {
|
|
name: "addRequest",
|
|
text: "CALL add_request($1,$2)"
|
|
}
|
|
|
|
export const checkValidState = {
|
|
name: "checkValidState",
|
|
text: "SELECT state FROM states WHERE state = $1"
|
|
}
|
|
|
|
export const updateRequestState = {
|
|
name: "updateRequestState",
|
|
text: "UPDATE requests SET state = $2 WHERE url = $1"
|
|
}
|
|
|
|
export const getRequestsWithEmptyMetadata = {
|
|
name: "getRequestsWithEmptyMetadata",
|
|
text: "SELECT url FROM requestMetadata WHERE videoTitle IS NULL"
|
|
}
|
|
|
|
export const updateRequestMetadata = {
|
|
name: "updateRequestState",
|
|
text: "UPDATE requestMetadata SET videoTitle = $2 WHERE url = $1"
|
|
}
|
|
|
|
export const updateRequestScoreModifier = {
|
|
name: "updateRequestScoreModifier",
|
|
text: "CALL update_request_score_modifier($1,$2)"
|
|
}
|
|
|
|
export const deleteRequest = {
|
|
name: "deleteRequest",
|
|
text: "DELETE FROM requests WHERE url = $1"
|
|
}
|
|
|
|
export const checkVoteExists = {
|
|
name: "checkVoteExists",
|
|
text: "SELECT userid FROM votes WHERE requesturl = $1 AND userid = $2"
|
|
}
|
|
|
|
export const getValidStates = {
|
|
name: "getValidStates",
|
|
text: "SELECT * FROM states"
|
|
}
|
|
|
|
export const getDbVersion = {
|
|
name: "getDbVersion",
|
|
text: "SELECT get_version()"
|
|
}
|