Skip to content

New rankings scores - #22

Closed
elcanadiano wants to merge 7 commits into
ihatecompvir:mainfrom
elcanadiano:new-rankings-scores
Closed

elcanadiano wants to merge 7 commits into
ihatecompvir:mainfrom
elcanadiano:new-rankings-scores

Conversation

@elcanadiano

Copy link
Copy Markdown

WARNING - THIS PULL REQUEST IS NOT MEANT TO BE MERGED. DO NOT MERGE. THIS PULL REQUEST IS ONLY MEANT TO DEMONSTRATE ARCHITECTURAL CHANGES. MERGING THIS PULL REQUEST SHOULD BE DONE IN PIECEMEAL

This brings in a role-rank endpoint which is based loosely off of the
aggregation pipeline that the existing Total Score ranks are based off
of.

We expect this implementation to be not performant if this goes into
production. What we aim is to create a replica of the My Rankings
sections. Then do a second implementation using a hypothetical new
collection which already would theoretically calculate role and
rank.
This introduces a dedicated collection which keeps track of a user's
cumulative Rock Band 3-only score and a total score, for a given role.
In order to properly populate each record, we have added a script
called rebuild_role_ranks, which will populate each role_rank record
given a user and their role.

From there, we also need to make sure that if a user puts up a high
score, we update the role_rank collection accordingly. That is what we
do in record.go with the ApplyRoleRankScoreDelta function.
This will set up a leaderboards/role-rank API endpoint which is similar
to the leaderboards/role-rank/legacy API endpoint, except it uses the
role_rank collection that we have set up.

We see some dramatic improvements already. Whereas a "Page 1" query
with 4 million simulated records took 1705.28ms on the legacy endpoint,
the newer endpoint took just 4.39ms. An inserted score from pid 5501
took 6191.78ms on the legacy endpoint whereas the new endpoint took
92.11ms.
When we set USE_MATERIALIZED_ROLE_RANKS to true, the jsonproto RB3 and
total score endpoints will instead use the role_ranks collections
instead of the MongoDB pipeline.

However, this commit keeps a version of the previous pipeline for use.
A future commit will remove the aggregate/pipeline implementation.
This will provide the last needed piece, providing an endpoint that
acts as two things - first we ensure we can get the basic information
of a user - their username, console, and PID. Then we get, where
possible, records of their Rock Band 3 and Total Scores, and their
ranks for them.
@elcanadiano
elcanadiano marked this pull request as draft September 22, 2026 22:28
@elcanadiano

elcanadiano commented Sep 22, 2026 •

Copy link
Copy Markdown
Author

Sorry I didn't mean to draft this into here. I'll invite you to formally look at this in my own fork if you would like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant