Fix leaderboard sorting
This commit is contained in:
parent
5360b128e0
commit
d4b2efe048
1 changed files with 3 additions and 3 deletions
|
@ -339,7 +339,7 @@ async def getMapLeaderboard(mapID, maxEntries):
|
||||||
del query["_id"]
|
del query["_id"]
|
||||||
leaderboard = query["Leaderboard"]
|
leaderboard = query["Leaderboard"]
|
||||||
|
|
||||||
return leaderboard
|
return sorted(leaderboard, key=lambda sort: sort["BestPlaytime"])[0:5]
|
||||||
|
|
||||||
|
|
||||||
@app.get("/api/v1/map/{mapID}/userbesttime/{userID}")
|
@app.get("/api/v1/map/{mapID}/userbesttime/{userID}")
|
||||||
|
@ -353,11 +353,11 @@ async def getPlayerRecord(mapID, userID):
|
||||||
|
|
||||||
# Find user
|
# Find user
|
||||||
replayIndex = None
|
replayIndex = None
|
||||||
|
BestTime = None
|
||||||
for i in range(len(leaderboard)):
|
for i in range(len(leaderboard)):
|
||||||
print(f"DBG: {i}, {leaderboard[i]}\t{leaderboard[i]['UserID'] == int(userID):}")
|
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
|
replayIndex = i
|
||||||
break
|
|
||||||
print(leaderboard[replayIndex])
|
print(leaderboard[replayIndex])
|
||||||
|
|
||||||
if replayIndex is not None:
|
if replayIndex is not None:
|
||||||
|
|
Loading…
Reference in a new issue