diff --git a/customiwmserver/main.py b/customiwmserver/main.py index e1fd344..0b99bd2 100644 --- a/customiwmserver/main.py +++ b/customiwmserver/main.py @@ -339,7 +339,7 @@ async def getMapLeaderboard(mapID, maxEntries): del query["_id"] leaderboard = query["Leaderboard"] - return leaderboard + return sorted(leaderboard, key=lambda sort: sort["BestPlaytime"])[0:5] @app.get("/api/v1/map/{mapID}/userbesttime/{userID}") @@ -353,11 +353,11 @@ async def getPlayerRecord(mapID, userID): # Find user replayIndex = None + BestTime = None for i in range(len(leaderboard)): print(f"DBG: {i}, {leaderboard[i]}\t{leaderboard[i]['UserID'] == int(userID):}") - if leaderboard[i]["UserID"] == int(userID): + if leaderboard[i]["UserID"] == int(userID) and (BestTime is None or leaderboard[i]["BestPlaytime"] < BestTime): replayIndex = i - break print(leaderboard[replayIndex]) if replayIndex is not None: