Comments (2)
For Personal Best Rank i found the issue seems to be the argument list, it seems to truncate the decimals from the number values, by changing https://github.com/osuAkatsuki/bancho.py/blob/master/app/api/domains/osu.py#L1205-L1217 to
p_best_rank = 1 + await app.state.services.database.fetch_val(
"SELECT COUNT(*) FROM scores s "
"INNER JOIN users u ON u.id = s.userid "
"WHERE s.map_md5 = :map_md5 AND s.mode = :mode "
"AND s.status = 2 AND u.priv & 1 "
f"AND s.{scoring_metric} > {personal_best_score_row['_score']}",
{
"map_md5": map_md5,
"mode": mode,
},
column=0, # COUNT(*)
)
seems to work
from bancho.py.
i might fixed it, doing a PR later on.
replace get_leaderboard_scores in app/api/domains/osu.py with
async def get_leaderboard_scores(
leaderboard_type: LeaderboardType | int,
map_md5: str,
mode: int,
mods: Mods,
player: Player,
scoring_metric: Literal["pp", "score"],
) -> tuple[list[dict[str, Any]], dict[str, Any] | None]:
query = [
f"SELECT s.id, s.{scoring_metric} AS _score, "
"s.max_combo, s.n50, s.n100, s.n300, "
"s.nmiss, s.nkatu, s.ngeki, s.perfect, s.mods, "
"UNIX_TIMESTAMP(s.play_time) time, u.id userid, "
"COALESCE(CONCAT('[', c.tag, '] ', u.name), u.name) AS name "
"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
"AND (u.priv & 1 OR u.id = :user_id) AND mode = :mode",
]
params: dict[str, Any] = {
"map_md5": map_md5,
"user_id": player.id,
"mode": mode,
}
if leaderboard_type == LeaderboardType.Mods:
query.append("AND s.mods = :mods")
params["mods"] = mods
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"]
# TODO: customizability of the number of scores
query.append("ORDER BY _score DESC, s.play_time ASC LIMIT 50")
score_rows = await app.state.services.database.fetch_all(
" ".join(query),
params,
)
if score_rows: # None or []
# fetch player's personal best score
personal_best_score_row = await app.state.services.database.fetch_one(
f"SELECT id, {scoring_metric} AS _score, "
"max_combo, n50, n100, n300, "
"nmiss, nkatu, ngeki, perfect, mods, "
"UNIX_TIMESTAMP(play_time) time "
"FROM scores "
"WHERE map_md5 = :map_md5 AND mode = :mode "
"AND userid = :user_id AND status = 2 "
"ORDER BY _score DESC LIMIT 1",
{"map_md5": map_md5, "mode": mode, "user_id": player.id},
)
if personal_best_score_row is not None:
# calculate the rank of the score.
p_best_rank = 1 + await app.state.services.database.fetch_val(
"SELECT COUNT(*) FROM scores s "
"INNER JOIN users u ON u.id = s.userid "
"WHERE s.map_md5 = :map_md5 AND s.mode = :mode "
"AND s.status = 2 AND u.priv & 1 "
f"AND (s.{scoring_metric} > {personal_best_score_row['_score']} OR s.{scoring_metric} = {personal_best_score_row['_score']} AND UNIX_TIMESTAMP(s.play_time) < {personal_best_score_row['time']})",
{
"map_md5": map_md5,
"mode": mode,
},
column=0, # COUNT(*)
)
# attach rank to personal best row
personal_best_score_row["rank"] = p_best_rank
else:
score_rows = []
personal_best_score_row = None
return score_rows, personal_best_score_row
from bancho.py.
Related Issues (20)
- Replace docker volumes with proper directory mounting
- misc: [06:40:35PM] [GET] 404 osu.magsec.ml/web/osu-session.php HOT 9
- misc: Add in readme to install docker desktop to make it available within ubuntu
- Support for per-mod personal best scores
- misc: spin up a temporary database for integration test suite
- misc: update docker image to not run as root HOT 1
- misc: determine a method to globally handle custom json serialization using `httpx` HOT 2
- misc: (TODO) make sure all repo `fetch_many` calls are using `page=None, page_size=None` where required by osu!
- bug: Handle case of clients marking match history as private in multi creation
- misc: Move achievements and default avatar into a submodule included with the project to avoid downloads
- misc: Create serialize() and deserialize() methods for each repo to enrich data quality HOT 2
- bug: Fix flakiness of "Test Application Code" CI job with regard to establishing mysql connection
- bug: !top doesn't work with offline players HOT 1
- bug: output for offline users in !user command is confusing HOT 1
- feat: make !recent work with offline players
- feat: make !purge to clear user plays - e.g. they are blatant/other. HOT 12
- feat: Split common nginx `server` block used for all routes into individual blocks to allow for extensibility
- misc: potentially separate base schema import from docker
- bug: clan leave doesn't update to cache
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bancho.py.