Optimize /update_points DB scoring path#47
Closed
mateu wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Optimizes the non-MySQL (“portable”) /update_points scoring implementation in Bracket::Model::DBIC to reduce DBIx::Class row-object inflation and replace per-row updates with more set-based SQL.
Changes:
- Switch portable-path lookup queries to
HashRefInflatorand hash-based lookups for game rounds, team seeds, and topology edges. - Replace object-heavy update loops with prepared SQL updates for
game(winner/lower_seed) andteam(round_out). - Rebuild
region_scorevia a singleINSERT ... SELECT(player×region cross join + aggregated winning picks), then recomputeplayer.pointswith one correlatedUPDATE; extend the test to assert zeroed rows for players with no winning picks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/Bracket/Model/DBIC.pm |
Reworks the portable scoring path to use hashref inflators + prepared statements + set-based rebuilds for region_score and player.points. |
t/model_update_points.t |
Adds coverage ensuring players with no winning picks still receive 4 zeroed region_score rows and a 0 total. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What: Optimize the database-heavy
update_pointspath (portable DBIC branch) by replacing object-heavy loops with set-based SQL and hashref lookups.Why:
/update_pointsis an admin hot path, and the previous portable implementation inflated many DBIx::Class row objects and performed per-row updates that scale poorly with player/pick volume.How: Use hashref inflators for topology/winner lookups, run prepared SQL updates for game/team mutations, and rebuild
region_scorein oneINSERT ... SELECT(cross-joining players/regions with aggregated winning picks), then recalculate player totals with one correlatedUPDATE.Testing: Ran
script/test-env.sh prove -lv t/model_update_points.t,script/test-env.sh prove -lr t, and syntax checks with repo-local env includes.Quality Report
Changes: 2 files changed, 143 insertions(+), 91 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline