From 09fc3ca882572cea2b81b86c596841b456cd93d9 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 24 May 2021 12:43:06 -0400 Subject: [PATCH] Raise reputation cap and don't count autovote submissions --- src/utils/reputation.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/reputation.ts b/src/utils/reputation.ts index d01de29..19d22d8 100644 --- a/src/utils/reputation.ts +++ b/src/utils/reputation.ts @@ -12,11 +12,12 @@ interface ReputationDBResult { export async function getReputation(userID: UserID): Promise { const pastDate = Date.now() - 1000 * 60 * 60 * 24 * 45; // 45 days ago + // 1596240000000 is August 1st 2020, a little after auto upvote was disabled const fetchFromDB = () => db.prepare("get", `SELECT COUNT(*) AS "totalSubmissions", SUM(CASE WHEN "votes" < 0 THEN 1 ELSE 0 END) AS "downvotedSubmissions", - SUM(CASE WHEN "votes" > 0 THEN "votes" ELSE 0 END) AS "upvotedSum", - SUM(CASE WHEN "timeSubmitted" < ? AND "votes" > 0 THEN 1 ELSE 0 END) AS "oldUpvotedSubmissions" + SUM(CASE WHEN "votes" > 0 AND "timeSubmitted" > 1596240000000 THEN "votes" ELSE 0 END) AS "upvotedSum", + SUM(CASE WHEN "timeSubmitted" < ? AND "timeSubmitted" > 1596240000000 AND "votes" > 0 THEN 1 ELSE 0 END) AS "oldUpvotedSubmissions" FROM "sponsorTimes" WHERE "userID" = ?`, [pastDate, userID]) as Promise; const result = await QueryCacher.get(fetchFromDB, reputationKey(userID)); @@ -35,7 +36,7 @@ export async function getReputation(userID: UserID): Promise { return 0; } - return convertRange(Math.min(result.upvotedSum, 50), 5, 50, 0, 15); + return convertRange(Math.min(result.upvotedSum, 150), 5, 150, 0, 15); } function convertRange(value: number, currentMin: number, currentMax: number, targetMin: number, targetMax: number): number {