From bc7624e001e2ae2f0babd98309655f601cef49f9 Mon Sep 17 00:00:00 2001 From: tgpethan Date: Sat, 13 Feb 2021 02:15:25 +0000 Subject: [PATCH] Get ready for dbhelper switch --- server/User.js | 7 ++++--- server/serverHandler.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/User.js b/server/User.js index 8867abb..040335e 100644 --- a/server/User.js +++ b/server/User.js @@ -57,7 +57,7 @@ module.exports = class { // Gets the user's score information from the database and caches it getNewUserInformationFromDatabase() { const userScoreDB = global.DatabaseHelper.getFromDB(`SELECT * FROM users_modes_info WHERE user_id = ${this.id} AND mode_id = ${this.playMode} LIMIT 1`); - const userRankDB = global.DatabaseHelper.getFromDB(`SELECT user_id, pp_raw, ROW_NUMBER() OVER(ORDER BY pp_raw DESC) AS rank FROM users_modes_info WHERE mode_id = ${this.playMode} ORDER BY pp_raw DESC`); + const userRankDB = global.DatabaseHelper.getFromDB(`SELECT user_id, pp_raw FROM users_modes_info WHERE mode_id = ${this.playMode} ORDER BY pp_raw DESC`); if (userScoreDB == null || userRankDB == null) throw "fuck"; @@ -70,8 +70,9 @@ module.exports = class { this.totalScore = userScoreDB.total_score; this.accuracy = userScoreDB.avg_accuracy; this.playCount = userScoreDB.playcount; - for (let userRank of userRankDB) - if (userRank["user_id"] == this.id) this.rank = userRank.rank; + for (let i = 0; i < userRankDB.length; i++) { + if (userRankDB[i]["user_id"] == this.id) this.rank = i + 1; + } this.pp = userScoreDB.pp_raw; if (userScoreUpdate) { diff --git a/server/serverHandler.js b/server/serverHandler.js index 59e3f70..1049841 100644 --- a/server/serverHandler.js +++ b/server/serverHandler.js @@ -120,7 +120,7 @@ const ChangeAction = require("./Packets/ChangeAction.js"), // A class for managing everything multiplayer global.MultiplayerManager = new MultiplayerManager(); -module.exports = function(req, res) { +module.exports = async function(req, res) { // Add to requests for logging global.httpRequestsPerLogInterval++;