osu-tournament-rating / otr-api

API powering osu! Tournament Rating
https://otr.stagec.xyz/
4 stars 2 forks source link

Allow queries for player stats to use optional ruleset #322

Closed myssto closed 1 month ago

myssto commented 1 month ago

This PR addresses two problems that exist between the frontend and the API:

To address the first problem, some changes were made to the way stat generation works. Now, if a request to /stats/{key} specifies a ruleset but the player has no data, instead of returning a 404 Not Found, it will return a PlayerStatsDTO with only the playerInfo populated. The endpoint will now correctly return a 404 Not Found only if no player exists for the given key.

For the second problem, we are able to leverage the new settings storage to determine a player's preferred ruleset without having to specify it in the query. Now, if a request is made to /stats/{key} without specifying a ruleset, stats for the player's default ruleset will be returned. This allows us to mimic the functionality of the osu! website where navigating to a user page will display their preferred ruleset by default but still allowing the viewing user to switch to different rulesets if they wish.

As a bonus, this fixes most of the issues that existed API side with versatile search. Namely, issues with spaces (#238) and not being able to search for players by osu! id.

Breaking Changes

Endpoint Changes

Schema Changes

Closes #238