Refactor update_points with portable DBIx fallback#27
Conversation
|
Issue linkage for pipeline/control-plane clarity: #30 This PR appears to be the implementation line for that issue. |
|
[bot:copilot-review-request] @copilot Please review this PR for correctness, regressions, edge cases, and any focused fixes needed before human handoff. Keep feedback scoped to the current PR. |
Agent-Logs-Url: https://github.com/mateu/Bracket/sessions/2b8cdfab-8515-426d-9817-7c8786a79693 Co-authored-by: mateu <31550+mateu@users.noreply.github.com>
Reviewed the PR. Two issues were found and fixed in commit
The rest of the logic reviewed clean:
|
There was a problem hiding this comment.
Pull request overview
Refactors Bracket::Model::DBIC->update_points to support non-MySQL databases by adding a portable DBIx::Class implementation while retaining the existing fast MySQL SQL path.
Changes:
- Added driver-aware dispatch for
update_points(mysqlvs portable DBIx::Class fallback). - Implemented a portable scoring/update pipeline (winner/lower-seed, team round_out, region_score, player points).
- Added
t/model_update_points.tregression coverage for the portable path on SQLite.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/Bracket/Model/DBIC.pm | Splits MySQL-specific SQL implementation from a new portable DBIx::Class fallback and shares stats formatting. |
| t/model_update_points.t | Adds SQLite regression test covering portable update behavior and score aggregation. |
| (5 + $game_row->get_column('lower_seed') * $team_row->get_column('seed')); | ||
| $points_for{$pick->get_column('player')}{ $team_row->get_column('region') } += $points_for_pick; | ||
| } |
There was a problem hiding this comment.
The portable points formula uses game.round * (5 + lower_seed * team.seed), matching the existing SQL path. However, Bracket::Controller::Admin::player_points currently applies a special-case multiplier of 10 when round == 6 (championship). If that special case is still intended, update_points (both mysql + portable) and this new regression test will compute different totals than the slow path. Consider aligning the scoring rule across code paths (or documenting why they differ).
lib/Bracket/Model/DBIC.pm
Outdated
| $_ . ': ' . sprintf('%.1f', 1000 * ($times->{$_} || 0)) | ||
| } sort { ($times->{$b} || 0) <=> ($times->{$a} || 0) } keys %{$times}; |
There was a problem hiding this comment.
_format_update_stats can be called with an empty %times hash (e.g., portable path when no perfect picks/current_round). In that case sum values %{$times} returns undef in List::Util, which can trigger uninitialized-value warnings during 1000 * $total_time. Consider defaulting to 0 via // 0 (and similarly for the per-key formatting) so this stays warning-free.
| $_ . ': ' . sprintf('%.1f', 1000 * ($times->{$_} || 0)) | |
| } sort { ($times->{$b} || 0) <=> ($times->{$a} || 0) } keys %{$times}; | |
| $_ . ': ' . sprintf('%.1f', 1000 * ($times->{$_} // 0)) | |
| } sort { ($times->{$b} // 0) <=> ($times->{$a} // 0) } keys %{$times}; |
|
[bot:copilot-fixup-request] @copilot Please address the actionable issues from your review on this PR as a new commit on the same branch. Keep scope limited to the current PR, avoid unrelated cleanup, and preserve existing intent. |
…discrepancy Agent-Logs-Url: https://github.com/mateu/Bracket/sessions/bbaa2799-0deb-4bcd-8a38-9cd413f7c610 Co-authored-by: mateu <31550+mateu@users.noreply.github.com>
Both review comments addressed in commit
|
What
Refactors
DBIC->update_pointsto keep the MySQL fast SQL path while adding a portable DBIx fallback for non-MySQL drivers.Why
update_pointswas explicitly MySQL-only and failed on SQLite, which made score updates untestable and inconsistent across environments.How
update_pointsinto driver-aware dispatch (mysqlSQL path, portable DBIx path)._format_update_statsshared output formatting andget_column(...)access to avoid relation/column collisions.t/model_update_points.tvalidating portable behavior on SQLite.Testing
script/test-env.sh prove -lv t/model_update_points.t t/BracketTestSchema.tscript/test-env.sh prove -lr tQuality Report
Changes: 2 files changed, 273 insertions(+), 30 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline