mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Improve performance of reputation query
This commit is contained in:
parent
280e6684af
commit
3894d453a5
1 changed files with 5 additions and 5 deletions
|
@ -31,14 +31,14 @@ export async function getReputation(userID: UserID): Promise<number> {
|
|||
SUM(CASE WHEN "timeSubmitted" < ? AND "timeSubmitted" > 1596240000000 AND "votes" > 0 THEN 1 ELSE 0 END) AS "semiOldUpvotedSubmissions",
|
||||
SUM(CASE WHEN "timeSubmitted" < ? AND "timeSubmitted" > 1596240000000 AND "votes" > 0 THEN 1 ELSE 0 END) AS "oldUpvotedSubmissions",
|
||||
SUM(CASE WHEN "votes" > 0
|
||||
AND NOT EXISTS (
|
||||
SELECT * FROM "sponsorTimes" as c
|
||||
WHERE (c."votes" > "a"."votes" OR c."locked" > "a"."locked") AND
|
||||
c."videoID" = "a"."videoID" AND
|
||||
c."category" = "a"."category" LIMIT 1)
|
||||
AND EXISTS (
|
||||
SELECT * FROM "lockCategories" as l
|
||||
WHERE l."videoID" = "a"."videoID" AND l."service" = "a"."service" AND l."category" = "a"."category" LIMIT 1)
|
||||
AND ("locked" > 0 OR NOT EXISTS (
|
||||
SELECT * FROM "sponsorTimes" as c
|
||||
WHERE (c."votes" > "a"."votes" OR c."locked" > "a"."locked") AND
|
||||
c."videoID" = "a"."videoID" AND
|
||||
c."category" = "a"."category" LIMIT 1) )
|
||||
THEN 1 ELSE 0 END) AS "mostUpvotedInLockedVideoSum"
|
||||
FROM "sponsorTimes" as "a" WHERE "userID" = ? AND "actionType" != 'full'`, [userID, weekAgo, pastDate, userID], { useReplica: true }) as Promise<ReputationDBResult>;
|
||||
|
||||
|
|
Loading…
Reference in a new issue