@@ -997,7 +997,7 @@ async def recalculate_and_update_first_place_scores(user_id: int) -> None:
997997 for rx , table_name in enumerate (("scores" , "scores_relax" , "scores_ap" )):
998998 order = "pp" if rx in (1 , 2 ) else "score"
999999 for score in await glob .db .fetchAll (
1000- "SELECT s.id, s.{order} AS score_value, s.play_mode, "
1000+ "SELECT s.id, s.{order} AS score_value, s.play_mode, s.time, "
10011001 "s.beatmap_md5, b.ranked FROM {t} s "
10021002 "LEFT JOIN beatmaps b USING(beatmap_md5) "
10031003 "WHERE s.userid = %s AND s.completed = 3 "
@@ -1009,7 +1009,7 @@ async def recalculate_and_update_first_place_scores(user_id: int) -> None:
10091009 # Get the current first place.
10101010 existing_first_place = await glob .db .fetch (
10111011 f"""
1012- SELECT scores_first.scoreid, scores_first.userid, scores.{ order } AS score_value
1012+ SELECT scores_first.scoreid, scores_first.userid, scores.{ order } AS score_value, time
10131013 FROM scores_first
10141014 INNER JOIN { table_name } AS scores ON scores.id = scores_first.scoreid
10151015 INNER JOIN users ON users.id = scores_first.userid
@@ -1023,9 +1023,12 @@ async def recalculate_and_update_first_place_scores(user_id: int) -> None:
10231023
10241024 # Check if our score is better than the current #1.
10251025 # If it is, then add/update scores_first.
1026- if (
1027- not existing_first_place
1028- or score ["score_value" ] > existing_first_place ["score_value" ]
1026+ if not existing_first_place or (
1027+ score ["score_value" ] > existing_first_place ["score_value" ]
1028+ or (
1029+ score ["score_value" ] == existing_first_place ["score_value" ]
1030+ and score ["time" ] < existing_first_place ["time" ]
1031+ )
10291032 ):
10301033 logging .info (
10311034 "Updating first place score" ,
0 commit comments