fix(multiplayer): fix acc bug on leaderboards

This commit is contained in:
chenjintang-shrimp
2025-08-08 18:21:15 +00:00
parent 698c0c2a81
commit c49c0481d0
2 changed files with 3 additions and 2 deletions

View File

@@ -61,8 +61,7 @@ class ItemAttemptsCount(ItemAttemptsCountBase, table=True):
self.pp = sum(score.score.pp for score in playlist_scores) self.pp = sum(score.score.pp for score in playlist_scores)
self.completed = len(playlist_scores) self.completed = len(playlist_scores)
self.accuracy = ( self.accuracy = (
sum(score.score.accuracy * score.attempts for score in playlist_scores) sum(score.score.accuracy for score in playlist_scores) / self.completed
/ self.completed
if self.completed > 0 if self.completed > 0
else 0.0 else 0.0
) )
@@ -111,4 +110,5 @@ class ItemAttemptsResp(ItemAttemptsCountBase):
) )
if "position" in include: if "position" in include:
resp.position = await item_attempts.get_position(session) resp.position = await item_attempts.get_position(session)
# resp.accuracy *= 100
return resp return resp

View File

@@ -169,6 +169,7 @@ async def get_room_leaderboard(
for i, agg in enumerate(aggs): for i, agg in enumerate(aggs):
resp = await ItemAttemptsResp.from_db(agg, db) resp = await ItemAttemptsResp.from_db(agg, db)
resp.position = i + 1 resp.position = i + 1
# resp.accuracy *= 100
aggs_resp.append(resp) aggs_resp.append(resp)
if agg.user_id == current_user.id: if agg.user_id == current_user.id:
user_agg = resp user_agg = resp