Skip to content

Refactor pick status logic into shared service#25

Draft
mateu wants to merge 1 commit intomasterfrom
koan/shared-pick-status-service
Draft

Refactor pick status logic into shared service#25
mateu wants to merge 1 commit intomasterfrom
koan/shared-pick-status-service

Conversation

@mateu
Copy link
Copy Markdown
Owner

@mateu mateu commented Mar 25, 2026

What

Extracted duplicate pick-status and winner-comparison logic into a shared Bracket::Service::PickStatus service, and switched Region/Final4/Admin code paths to consume it.

Why

Region, Final4, and Admin::player_points each reimplemented the same in/out/pending winner checks with small variations. That made behavior drift more likely and multiplied query overhead/maintenance cost.

How

Added PickStatus helpers for loading player picks, building pick maps, loading perfect-winner picks, and classifying each pick as in, out, or pending.
Replaced duplicated loops in Region::view, Final4::make, Final4::view, and Admin::player_points with service calls while preserving existing scoring formulas and templates.
Added a DB-backed t/pick_status.t to lock service behavior.

Testing

  • script/test-env.sh prove -lv t/pick_status.t t/controller_Region.t t/bracket_validator.t
  • script/test-env.sh prove -lr t

Quality Report

Changes: 5 files changed, 151 insertions(+), 129 deletions(-)

Code scan: clean

Tests: skipped

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

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