Skip to content
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

feat: denormalize and restore the Followed Users Ranking component #2448

Conversation

wescopeland
Copy link
Member

This PR restores the Followed Users Ranking component on user profiles. The component was previously replaced with a call-to-action due to how intensive it was in regards to DB performance. Now, player daily and weekly points summaries are denormalized into the player_stats table so the DB calls for the component are now essentially free, even for users that are following 1000+ other users.

This PR is stacked on top of #2446.

Before
Screenshot 2024-05-19 at 2 17 52 PM

After
Screenshot 2024-05-19 at 2 17 35 PM

How it works:

  • A new job has been written, UpdatePlayerPointsStats, which inserts denormalized points summary values for a user's daily/weekly hardcore, weighted, and softcore points into the player_stats table.
  • The job has been configured to dispatch on PlayerMetricsUpdated and on PlayerRankedStatusChanged.
  • For existing records only, the job has been configured to dispatch every hour to keep them up to date.
  • When a record value hits 0, it is hard deleted from player_stats by a tiny command: DeleteStalePlayerPointsStatsEntries. This can't be inside UpdatePlayerPointsStats itself without causing race conditions.

How to test this PR:
UpdatePlayerPointsStats is exposed through a new Artisan Console command. The command also accepts mock dates to improve testing.

## For async stuff, be sure to restart Horizon after pulling down this branch.

# Synchronously write points summaries for one user
sail artisan ra:platform:player:update-points-stats Jamiras

# Synchronously write points summaries for one user for a specific date
sail artisan ra:platform:player:update-points-stats Jamiras --date="2023-11-05"

# Kick off jobs to write points summaries for all users on a specific date
sail artisan ra:platform:player:update-points-stats --date="2023-11-05"

# Kick off jobs to update only existing points summaries for the current date
sail artisan ra:platform:player:update-points-stats --existing-only

# Kick off jobs to write points summaries for all users for the current date
sail artisan ra:platform:player:update-points-stats

@wescopeland wescopeland requested a review from a team May 19, 2024 18:35
docker-compose.yml Outdated Show resolved Hide resolved
app/Platform/EventServiceProvider.php Show resolved Hide resolved
@wescopeland
Copy link
Member Author

Preferably would like to see this one not included in 6.7.0, as there's already quite a bit of things merged for 6.7.0 and this one should be watched closely.

If no objections, let's push this one to the release afterwards.

@wescopeland wescopeland merged commit a5a32ca into RetroAchievements:master Jun 17, 2024
5 checks passed
@wescopeland wescopeland deleted the denormalized-followed-users-ranking branch June 17, 2024 11:45
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.

2 participants