texts for getTopCategoryUsers

This commit is contained in:
Michael C
2021-12-30 04:07:38 -05:00
parent 98994cee01
commit f97af4c433
2 changed files with 127 additions and 3 deletions

View File

@@ -24,9 +24,9 @@ async function generateTopCategoryUsersStats(sortBy: string, category: string) {
SUM(((CASE WHEN "sponsorTimes"."endTime" - "sponsorTimes"."startTime" > ? THEN ? ELSE "sponsorTimes"."endTime" - "sponsorTimes"."startTime" END) / 60) * "sponsorTimes"."views") as "minutesSaved",
SUM("votes") as "userVotes", COALESCE("userNames"."userName", "sponsorTimes"."userID") as "userName" FROM "sponsorTimes" LEFT JOIN "userNames" ON "sponsorTimes"."userID"="userNames"."userID"
LEFT JOIN "shadowBannedUsers" ON "sponsorTimes"."userID"="shadowBannedUsers"."userID"
WHERE category = ? AND "sponsorTimes"."votes" > -1 AND "sponsorTimes"."shadowHidden" != 1 AND "shadowBannedUsers"."userID" IS NULL
WHERE "sponsorTimes"."category" = ? AND "sponsorTimes"."votes" > -1 AND "sponsorTimes"."shadowHidden" != 1 AND "shadowBannedUsers"."userID" IS NULL
GROUP BY COALESCE("userName", "sponsorTimes"."userID") HAVING SUM("votes") > 20
ORDER BY "${sortBy}" DESC LIMIT 100`, [category, maxRewardTimePerSegmentInSeconds, maxRewardTimePerSegmentInSeconds]);
ORDER BY "${sortBy}" DESC LIMIT 100`, [maxRewardTimePerSegmentInSeconds, maxRewardTimePerSegmentInSeconds, category]);
for (const row of rows) {
userNames.push(row.userName);
@@ -47,7 +47,7 @@ export async function getTopCategoryUsers(req: Request, res: Response): Promise<
const sortType = parseInt(req.query.sortType as string);
const category = req.query.category as string;
if (sortType == undefined || config.categoryList.includes(category) ) {
if (sortType == undefined || !config.categoryList.includes(category) ) {
//invalid request
return res.sendStatus(400);
}