-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show changes to user statistics in-game #18877
Comments
@arflyte I brought this up with you a while ago, curious if you have anything yet? |
Unfortunately no, I haven't got to this yet. |
@arflyte any updates? |
@arflyte any update? |
The lack of design aside, the thing I'm wondering here is: how should the data for the display be retrieved? Now I haven't exactly been keeping up with infra, but on a five minute look the current flow looks to be:
Do I have this right? If so, then the immediate issue is that while this system does have eventual consistency, there is no guarantee that the stats update is received before the results screen is shown. The obvious option is to poll periodically and see if user stats change - is this fine, or should the solution be smarter than this somehow? |
Everything there is correct thinking, yes. I do believe we'd eventually want a push flow for this, potentially via Or maybe polling will work for now, up to you really. I think getting a flow in place even without a design would be a great starting point. |
One thing I should probably mention is that for replay saving, it's only relying on the score being fulfilled (ie. inserted into An entry will only be inserted once processing has completed. |
Puttng the pieces together, I think I might have a vague vision in mind of how the push flow could work, but I'd probably be looking to base it on
so I presume that the DBMS is going to fill in valid data there because of the default and the trigger. I guess timezones/clock sync may be an issue (but one that can be circumvented rather easily by querying latest Without this field it's really difficult to not have to look up the entire table to scan for new changes. While The other thing that worries me is that if this does become based on |
So there's two ways I can imagine this working.
Also I don't think you need to worry about the I'd probably also see a similar process to replay saving, where |
The prospect of having a full flow without polling using redis pubsub is tempting. I guess I'll try that first and dumb down as required if too many complications arise. |
Tend to agree. Polling regardless of how it's done is going to end up being ugly due to parallel processing considerations server-side (scores may not be processed in perfect sequential order). |
So after a weekend of experimenting I have a... semblance? of a working flow with no polling. In full, at a high level, it looks like this: sequenceDiagram
critical Set up redis pubsub channel
Note over osu-server-spectator,redis: Happens at osu-server-spectator startup.
osu-server-spectator ->> redis: SUBSCRIBE osu-channel:score:processed
redis -->> osu-server-spectator: ACK
end
critical Set up signalr channel
Note over osu,osu-server-spectator: Happens at osu startup.
osu ->> osu-server-spectator: SpectatorClient.OnUserScoreProcessed +=<br>(int userId, long scoreId) => { ... }
osu-server-spectator -->> osu: ACK
end
critical Set up statistics watcher
Note over osu,osu-web: Happens at osu startup.
osu ->> osu-web: GET /users/?ids[]={localUserId}
osu-web -->> osu: UserCompact<br>(with user stats for all rulesets)
end
Note over osu-server-spectator,osu-queue-score-statistics: Score submission flow begins here.
osu ->> osu-web: PUT /beatmaps/{beatmapId}/solo/scores/{tokenId}
osu-web -->> osu: MultiplayerScore (with populated online ID)
par
osu ->>+ osu-server-spectator: SpectatorClient.EndPlaying(SpectatorState)
Note over osu-server-spectator: osu client is implicitly subscribed<br>for notifications about score<br>with ID from spectator state.
osu-server-spectator -->>- osu: ACK
and
osu-web ->>+ redis: LPUSH osu-queue:score-statistics, Score { id: ... }
redis -->>- osu-web: ACK
Note over osu-queue-score-statistics,redis: At some indeterminate point later on...
osu-queue-score-statistics ->>+ redis: RPOP osu-queue:score-statistics
redis -->>- osu-queue-score-statistics: Score { id: ... }
Note over osu-queue-score-statistics: Score is processed.
osu-queue-score-statistics ->> redis: PUBLISH osu-channel:score:processed<br>ScoreProcessed { scoreId: ..., processedVersion: ... }
redis -->> osu-queue-score-statistics: ACK
redis -) osu-server-spectator: ScoreProcessed { scoreId: ..., processedVersion: ... }
osu-server-spectator -) osu: SpectatorClient.UserScoreProcessed(userId, scoreId)
osu ->>+ osu-web: GET /me/{rulesetName}
osu-web -->>- osu: UserCompact<br>(with stats for last play ruleset)
Note over osu: Compute differences in stats<br>and display to user.
end
Questions at this point are:
The code I have is working but quite dirty, so I need to do cleanup before it can be PRed. But there's something there. |
Let's mark this as closed. Thanks to @bdach for the work on the initial implementation (finalised with ppy/osu-server-spectator#157 and #21778). |
Building on the initial implementation that only provides the equivalent of stable's "overall ranking", I also attempted to add "beatmap ranking" back, and found that it may be feasible to add that back with relatively low effort and just via client-side changes. Structure would be very similar to what's in place (i.e. all of the work would be done client-side, leveraging web via the API). Would that be something we'd be interested in getting in place short term, or should I wait and see how the current flow holds up for now? |
Currently there is no replacement for stable's scrollable results screen, which shows changes to online statistics after the gameplay loop. We need to add something similar, and potentially consider cases where statistics change outside the results screen.
The text was updated successfully, but these errors were encountered: