Open yuyuko-s opened 1 month ago
Hi, this is because the rank is not actually stored anywhere, but rather its computed on the fly when doing a request to the /ranking
endpoint. So this is sadly a bit more complicated than just adding a new field to the API response, as it'd require us to cache the rank.
Thanks for the quick response. You mentioned in the /ranking/ documentation that the endpoint is relatively slow. Perhaps it would be faster to cache the rank anyways? Instead of calculating the ranks every time someone makes a request to /ranking/, you would only have to calculate the rank when a record is added, player is banned etc.
Thanks for the quick response. You mentioned in the /ranking/ documentation that the endpoint is relatively slow.
Ah, funnily enough that's outdated, because nowaday the response to that endpoint is mostly cached
Perhaps it would be faster to cache the rank anyways? Instead of calculating the ranks every time someone makes a request to /ranking/, you would only have to calculate the rank when a record is added, player is banned etc.
We already cache the score, so most of the infrastructure for when to trigger updates to the cached values would already be there.
That said, wouldn't you need two requests anyway? One to resolve the player name to an ID and then another to grab the records?
Hi, thanks for the information about this issue. To answer your question, I only store players by their ID. The only time I have to resolve an ID from a name is when users search for a player by their username, but I almost always have player information cached. Having the rank included in the full form of a player would make it so I would only need one request to cache a player rather than two.
Ah, I see. Yes, that sounds valid. @emonadeo at some point mentioned overhaulting this all with materialized views to implement #132, so probably including rank can be done as part of that :)
The full form of a player doesn't include their stats viewer rank. Currently, I have to make two separate requests to get a player's records and a player's rank.