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++;