mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Reformat SQL code in postBranding.ts webhook code
This commit is contained in:
parent
72086b0195
commit
380ec8d0ca
1 changed files with 21 additions and 2 deletions
|
@ -292,11 +292,30 @@ export async function verifyOldSubmissions(hashedUserID: HashedUserID, verificat
|
|||
}
|
||||
|
||||
async function sendWebhooks(videoID: VideoID, UUID: BrandingUUID, voteType: BrandingVoteType) {
|
||||
const currentSubmission = await db.prepare("get", `SELECT "titleVotes"."votes", "titles"."title", "titleVotes"."locked", "titles"."userID", "titleVotes"."votes"-"titleVotes"."downvotes"+"titleVotes"."verification" AS "score" FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID" WHERE "titles"."UUID" = ?`, [UUID]);
|
||||
const currentSubmission = await db.prepare(
|
||||
"get",
|
||||
`SELECT
|
||||
"titles"."title",
|
||||
"titleVotes"."locked",
|
||||
"titles"."userID",
|
||||
"titleVotes"."votes"-"titleVotes"."downvotes"+"titleVotes"."verification" AS "score"
|
||||
FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID"
|
||||
WHERE "titles"."UUID" = ?`,
|
||||
[UUID]);
|
||||
|
||||
// Unlocked title getting more upvotes than the locked one
|
||||
if (voteType === BrandingVoteType.Upvote) {
|
||||
const lockedSubmission = await db.prepare("get", `SELECT "titleVotes"."votes", "titles"."title", "titles"."userID", "titleVotes"."votes"-"titleVotes"."downvotes"+"titleVotes"."verification" AS "score" FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID" WHERE "titles"."videoID" = ? AND "titles"."UUID" != ? AND "titleVotes"."locked" = 1`, [videoID, UUID]);
|
||||
const lockedSubmission = await db.prepare(
|
||||
"get",
|
||||
`SELECT
|
||||
"titles"."title",
|
||||
"titles"."userID",
|
||||
"titleVotes"."votes"-"titleVotes"."downvotes"+"titleVotes"."verification" AS "score"
|
||||
FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID"
|
||||
WHERE "titles"."videoID" = ?
|
||||
AND "titles"."UUID" != ?
|
||||
AND "titleVotes"."locked" = 1`,
|
||||
[videoID, UUID]);
|
||||
|
||||
// Time to warn that there may be an issue
|
||||
if (lockedSubmission && currentSubmission.score - lockedSubmission.score > 2) {
|
||||
|
|
Loading…
Reference in a new issue