Add user season score calculation workflow #11768
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #8736.
Serving as a base for implementation of seasonal rankings in nearing feature.
This mimics the Beatmap Spotlights seasonal rankings calculation process that used to be done via an external script.
Also adds an artisan command for score recalculating.
Tried to optimize the calculation process as much as possible, any further potential improvements on that matter would be vastly appreciated. 🤔
How does this work?
Rooms
The seasons are designed as a series of few (currently: three) playlists that are usually labeled by consecutive letters of alphabet (A, B, C).
Each of the playlists is ran twice over a course of the season. For the sake of this implementation, the rooms of the first run of the playlists are referred to as "parent rooms", while the rooms of the second run are called "children rooms".
This PR adds
parent_id
field to themultiplayer_rooms
table, to be used on children rooms.Score calculation
Total (user) season score is sum of best playlist total scores achieved throughout the season, with added factor-based weighting.
Total scores of a each playlist are compared between the parent and child rooms, with higher being taken for total season score calculation.
Said scores are sorted from highest to lowest, and season-specified factors are being applied in descending order to each of them (e.g. 1.0, 0.75, 0.5). This results in final total season score.
This PR adds the following:
user_season_scores
table,total_score
of which is calculated using related modelcalculate()
function, that is called whenever user places a score on related season's room.season_score_factors
table, that stores factors, used for total season score calculation.Example user total season score calculation
Let's say a user achieves following scores during the six playlists of the season:
The season score factors are set to following: 1, 0.75, 0.5.
Playlist final scores are being sorted in descending order, resulting in following values: 40, 20, 12. The final season score calculation goes as below:
The total season score is 61. That value would be used for sake of placing user in seasonal leaderboard.