From fa972bab37f711b7bf43fdc6947f76192525c1fc Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 1 Apr 2024 21:08:00 -0400 Subject: [PATCH] Don't include banned users on rankings --- db/daily.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/daily.go b/db/daily.go index f0a372e..2d85b41 100644 --- a/db/daily.go +++ b/db/daily.go @@ -32,9 +32,9 @@ func FetchRankings(category int, page int) ([]defs.DailyRanking, error) { var query string switch category { case 0: - query = "SELECT RANK() OVER (ORDER BY adr.score DESC, adr.timestamp), a.username, adr.score, adr.wave FROM accountDailyRuns adr JOIN dailyRuns dr ON dr.date = adr.date JOIN accounts a ON adr.uuid = a.uuid WHERE dr.date = UTC_DATE() LIMIT 10 OFFSET ?" + query = "SELECT RANK() OVER (ORDER BY adr.score DESC, adr.timestamp), a.username, adr.score, adr.wave FROM accountDailyRuns adr JOIN dailyRuns dr ON dr.date = adr.date JOIN accounts a ON adr.uuid = a.uuid WHERE dr.date = UTC_DATE() AND a.banned = 0 LIMIT 10 OFFSET ?" case 1: - query = "SELECT RANK() OVER (ORDER BY SUM(adr.score) DESC, adr.timestamp), a.username, SUM(adr.score), 0 FROM accountDailyRuns adr JOIN dailyRuns dr ON dr.date = adr.date JOIN accounts a ON adr.uuid = a.uuid WHERE dr.date >= DATE_SUB(DATE(UTC_TIMESTAMP()), INTERVAL DAYOFWEEK(UTC_TIMESTAMP()) - 1 DAY) GROUP BY a.username ORDER BY 1 LIMIT 10 OFFSET ?" + query = "SELECT RANK() OVER (ORDER BY SUM(adr.score) DESC, adr.timestamp), a.username, SUM(adr.score), 0 FROM accountDailyRuns adr JOIN dailyRuns dr ON dr.date = adr.date JOIN accounts a ON adr.uuid = a.uuid WHERE dr.date >= DATE_SUB(DATE(UTC_TIMESTAMP()), INTERVAL DAYOFWEEK(UTC_TIMESTAMP()) - 1 DAY) AND a.banned = 0 GROUP BY a.username ORDER BY 1 LIMIT 10 OFFSET ?" } results, err := handle.Query(query, offset)