Skip to content

Commit

Permalink
Don't show banned users on the leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Jul 26, 2020
1 parent 4bfa5e7 commit 986c9dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/databases/databases.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ if (config.mysql) {
if (fs.existsSync(config.privateDBSchema)) privateDB.exec(fs.readFileSync(config.privateDBSchema).toString());
}

// Upgrade database if required
if (!config.readOnly) {
// Upgrade database if required
ugradeDB(db, "sponsorTimes");
ugradeDB(privateDB, "private")

// Attach private db to main db
db.prepare("ATTACH ? as privateDB").run(config.privateDB);
}

// Enable WAL mode checkpoint number
Expand Down
4 changes: 3 additions & 1 deletion src/routes/getTopUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ module.exports = function getTopUsers (req, res) {
"SUM((sponsorTimes.endTime - sponsorTimes.startTime) / 60 * sponsorTimes.views) as minutesSaved, " +
additionalFields +
"IFNULL(userNames.userName, sponsorTimes.userID) as userName FROM sponsorTimes LEFT JOIN userNames ON sponsorTimes.userID=userNames.userID " +
"WHERE sponsorTimes.votes > -1 AND sponsorTimes.shadowHidden != 1 GROUP BY IFNULL(userName, sponsorTimes.userID) ORDER BY " + sortBy + " DESC LIMIT 100", []);
"LEFT JOIN privateDB.shadowBannedUsers ON sponsorTimes.userID=privateDB.shadowBannedUsers.userID " +
"WHERE sponsorTimes.votes > -1 AND sponsorTimes.shadowHidden != 1 AND privateDB.shadowBannedUsers.userID IS NULL " +
"GROUP BY IFNULL(userName, sponsorTimes.userID) ORDER BY " + sortBy + " DESC LIMIT 100", []);

for (let i = 0; i < rows.length; i++) {
userNames[i] = rows[i].userName;
Expand Down

0 comments on commit 986c9dc

Please sign in to comment.