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

perf(site-award): query for game_sets in SeparateAwards() #3066

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wescopeland
Copy link
Member

This PR migrates SeparateAwards() to use game_sets instead of GameAlternatives.

After #3065 is merged, to the best of my knowledge, this is the only place actually querying for GameAlternatives.

While working on this function, I couldn't help but notice that SeparateAwards() is wildly inefficient. With the changes in this PR, I was able to drop the number of queries on at least one developer's user profile by ~40.

This PR:

  • Consolidates all the queries into a single optimized query using whereIn.
  • Uses array flipping for O(1) lookups instead of repeated array searches.
  • Pre-calculates award type checks to avoid redundant calls.
  • Processes awards in a single execution pass wherever possible.
  • Uses early returns to skip unnecessary processing for empty event awards.

@wescopeland wescopeland requested a review from a team January 16, 2025 02:09
@wescopeland
Copy link
Member Author

After #3067 is merged, I will fix this branch.

@wescopeland wescopeland marked this pull request as draft January 17, 2025 02:25
@wescopeland wescopeland marked this pull request as ready for review January 19, 2025 21:20
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