From e06436abb909bd2161fe06fadf0add94f5bd73c3 Mon Sep 17 00:00:00 2001 From: Josh Smith Date: Mon, 10 Dec 2018 04:12:36 -0500 Subject: [PATCH] Show score for loved maps on relax rather than PP --- handlers/getReplayHandler.py | 1 - helpers/consoleHelper.py | 2 +- objects/relaxboard.pyx | 26 +++++++++++++++++++------- objects/scoreboard.pyx | 1 - 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/handlers/getReplayHandler.py b/handlers/getReplayHandler.py index 6545ca2..36b4420 100644 --- a/handlers/getReplayHandler.py +++ b/handlers/getReplayHandler.py @@ -60,7 +60,6 @@ class handler(requestsManager.asyncRequestHandler): if username != replayData["uname"]: userUtils.incrementReplaysWatched(replayData["userid"], replayData["play_mode"], s.mods) - log.info("Serving replay_{}.osr".format(replayID)) fileName = ".data/replays/replay_{}.osr".format(replayID) if os.path.isfile(fileName): diff --git a/helpers/consoleHelper.py b/helpers/consoleHelper.py index 1aa7e8c..443ff61 100644 --- a/helpers/consoleHelper.py +++ b/helpers/consoleHelper.py @@ -23,7 +23,7 @@ def printServerStartHeader(asciiArt): printColored("> Welcome to the Latest Essential Tatoe Server v{}".format(glob.VERSION), bcolors.GREEN) printColored("> Made by the Ripple and Akatsuki teams", bcolors.GREEN) - printColored("> {}https://github.com/cmyui/lets".format(bcolors.UNDERLINE), bcolors.GREEN) + printColored("> {}https://github.com/osuAkatsuki/lets".format(bcolors.UNDERLINE), bcolors.GREEN) printColored("> Press CTRL+C to exit\n", bcolors.GREEN) diff --git a/objects/relaxboard.pyx b/objects/relaxboard.pyx index 54d06bd..6fa2d76 100644 --- a/objects/relaxboard.pyx +++ b/objects/relaxboard.pyx @@ -71,7 +71,11 @@ class scoreboard: friends = "" # Sort and limit at the end - order = "ORDER BY pp DESC" + if self.beatmap.rankedStatus == rankedStatuses.LOVED: + order = "ORDER BY score DESC" + else: + order = "ORDER BY pp DESC" + limit = "LIMIT 1" # Build query, get params and run query @@ -116,7 +120,10 @@ class scoreboard: else: friends = "" - order = "ORDER BY pp DESC" + if self.beatmap.rankedStatus == rankedStatuses.LOVED: + order = "ORDER BY score DESC" + else: + order = "ORDER BY pp DESC" if isPremium: # Premium members can see up to 100 scores on leaderboards limit = "LIMIT 100" @@ -199,9 +206,9 @@ class scoreboard: # We have a score, run the huge query # Base query - query = """SELECT COUNT(*) AS rank FROM scores_relax STRAIGHT_JOIN users ON scores_relax.userid = users.id STRAIGHT_JOIN users_stats ON users.id = users_stats.id WHERE scores_relax.pp >= ( - SELECT pp FROM scores_relax WHERE beatmap_md5 = %(md5)s AND play_mode = %(mode)s AND completed = 3 AND userid = %(userid)s LIMIT 1 - ) AND scores_relax.beatmap_md5 = %(md5)s AND scores_relax.play_mode = %(mode)s AND scores_relax.completed = 3 AND users.privileges & 1 > 0""" + query = """SELECT COUNT(*) AS rank FROM scores_relax STRAIGHT_JOIN users ON scores_relax.userid = users.id STRAIGHT_JOIN users_stats ON users.id = users_stats.id WHERE scores_relax.{PPorScore} >= ( + SELECT {PPorScore} FROM scores_relax WHERE beatmap_md5 = %(md5)s AND play_mode = %(mode)s AND completed = 3 AND userid = %(userid)s LIMIT 1 + ) AND scores_relax.beatmap_md5 = %(md5)s AND scores_relax.play_mode = %(mode)s AND scores_relax.completed = 3 AND users.privileges & 1 > 0""".format(PPorScore="score" if self.beatmap.rankedStatus == rankedStatuses.LOVED else "pp") # Country if self.country: query += " AND users_stats.country = (SELECT country FROM users_stats WHERE id = %(userid)s LIMIT 1)" @@ -212,7 +219,12 @@ class scoreboard: if self.friends: query += " AND (scores_relax.userid IN (SELECT user2 FROM users_relationships WHERE user1 = %(userid)s) OR scores_relax.userid = %(userid)s)" # Sort and limit at the end - query += " ORDER BY pp DESC LIMIT 1" + + if self.beatmap.rankedStatus == rankedStatuses.LOVED: + query += " ORDER BY score DESC LIMIT 1" + else: + query += " ORDER BY pp DESC LIMIT 1" + result = glob.db.fetch(query, {"md5": self.beatmap.fileMD5, "userid": self.userID, "mode": self.gameMode, "mods": self.mods}) if result is not None: self.personalBestRank = result["rank"] @@ -237,5 +249,5 @@ class scoreboard: # Output top 50 scores for i in self.scores[1:]: - data += i.getData(pp=1) + data += i.getData(pp=self.beatmap.rankedStatus != rankedStatuses.LOVED) return data diff --git a/objects/scoreboard.pyx b/objects/scoreboard.pyx index fcc9a10..0aac8b5 100644 --- a/objects/scoreboard.pyx +++ b/objects/scoreboard.pyx @@ -29,7 +29,6 @@ class scoreboard: if setScores: self.setScores() - def setScores(self): """ Set scores list