2020-09-15 05:45:32 +00:00
|
|
|
// 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"
|
|
|
|
}
|
|
|
|
|
2020-09-15 06:01:11 +00:00
|
|
|
export const checkBan = {
|
|
|
|
name: "checkBan",
|
|
|
|
text: "SELECT userid FROM bans WHERE userid = $1"
|
|
|
|
}
|
|
|
|
|
2020-09-15 05:45:32 +00:00
|
|
|
// 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 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",
|
2020-09-21 00:22:07 +00:00
|
|
|
text: "SELECT * FROM requests_vw \
|
|
|
|
JOIN states ON requests_vw.state = states.state \
|
|
|
|
WHERE active LIMIT $1"
|
2020-09-15 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const getRequestsVoted = {
|
|
|
|
name: "getRequestsVoted",
|
2020-09-21 00:22:07 +00:00
|
|
|
text: "SELECT * FROM get_requests_voted($2) \
|
|
|
|
JOIN states ON get_requests_voted.state = states.state \
|
|
|
|
WHERE active LIMIT $1"
|
2020-09-15 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const getAllRequests = {
|
|
|
|
name: "getAllRequests",
|
2020-09-21 00:22:07 +00:00
|
|
|
text: "SELECT * FROM requests_vw() LIMIT $1"
|
2020-09-15 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const getAllRequestsVoted = {
|
|
|
|
name: "getAllRequestsVoted",
|
2020-09-21 00:22:07 +00:00
|
|
|
text: "SELECT * FROM get_requests_voted($2) LIMIT $1"
|
2020-09-15 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const checkRequestExists = {
|
|
|
|
name: "checkRequestExists",
|
2020-09-15 06:01:11 +00:00
|
|
|
text: "SELECT url FROM requests WHERE url = $1"
|
2020-09-15 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const addRequest = {
|
|
|
|
name: "addRequest",
|
|
|
|
text: "CALL add_request($1,$2)"
|
|
|
|
}
|
|
|
|
|
|
|
|
export const checkValidState = {
|
|
|
|
name: "checkValidState",
|
2020-09-15 06:01:11 +00:00
|
|
|
text: "SELECT state FROM states WHERE state = $1"
|
2020-09-15 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const updateRequestState = {
|
|
|
|
name: "updateRequestState",
|
|
|
|
text: "UPDATE requests SET state = $2 WHERE url = $1"
|
|
|
|
}
|
|
|
|
|
2020-10-19 00:24:24 +00:00
|
|
|
export const updateRequestScoreModifier = {
|
|
|
|
name: "updateRequestScoreModifier",
|
|
|
|
text: "CALL update_request_score_modifier($1,$2)"
|
2020-09-15 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const deleteRequest = {
|
|
|
|
name: "deleteRequest",
|
|
|
|
text: "DELETE FROM requests WHERE url = $1"
|
|
|
|
}
|
|
|
|
|
|
|
|
export const checkVoteExists = {
|
|
|
|
name: "checkVoteExists",
|
2020-09-15 06:01:11 +00:00
|
|
|
text: "SELECT userid FROM votes WHERE requesturl = $1 AND userid = $2"
|
2020-09-15 05:45:32 +00:00
|
|
|
}
|