Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: per-mod personal best score on leaderboard #442

Closed
wants to merge 10 commits into from
6 changes: 5 additions & 1 deletion app/api/domains/osu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ async def get_leaderboard_scores(
"FROM scores s "
"INNER JOIN users u ON u.id = s.userid "
"LEFT JOIN clans c ON c.id = u.clan_id "
"WHERE s.map_md5 = :map_md5 AND s.status = 2 " # 2: =best score
"WHERE s.map_md5 = :map_md5 "
"AND (u.priv & 1 OR u.id = :user_id) AND mode = :mode",
]

Expand All @@ -1303,13 +1303,17 @@ async def get_leaderboard_scores(
if leaderboard_type == LeaderboardType.Mods:
query.append("AND s.mods = :mods")
params["mods"] = mods
query.append("AND s.status IN (1, 2)") # 1 = submitted, 2 = best
elif leaderboard_type == LeaderboardType.Friends:
query.append("AND s.userid IN :friends")
params["friends"] = player.friends | {player.id}
elif leaderboard_type == LeaderboardType.Country:
query.append("AND u.country = :country")
params["country"] = player.geoloc["country"]["acronym"]

if leaderboard_type != LeaderboardType.Mods:
query.append("AND s.status = 2")

# TODO: customizability of the number of scores
query.append("ORDER BY _score DESC LIMIT 50")

Expand Down