Skip to content

Recompute basho results after entering picks - #183

Merged
danieldickison merged 2 commits into
mainfrom
enter-picks-recompute-results
Sep 14, 2026
Merged

danieldickison merged 2 commits into
mainfrom
enter-picks-recompute-results

Conversation

@danieldickison

Copy link
Copy Markdown
Owner

enter-picks writes pick rows but the standings table (basho_result) is only rebuilt by update_torikumi, so a straggler entered mid-basho was missing from the rankings until the next day's results were imported.

force_save_player_picks now calls upsert_basho_results(&txn, basho_id, false) in the same transaction as the pick replacement — the same call update_torikumi makes. It recomputes wins and rank for every player in the basho, not just the new one, since inserting a player shifts everyone below them. bestow_awards: false means the award table is untouched, and player_rank is left to finalize_basho where it belongs. The web-facing save_player_picks is deliberately unchanged: those picks always land before the basho starts, so there is nothing to compute.

The CLI's now-false "scores are recalculated when the next torikumi is imported" note is gone, and the success message says the results were recomputed. Default RUST_LOG drops to warn because upsert_basho_results logs at info and was printing itself right after the [y/N] prompt; RUST_LOG=info still shows it.

Testing

Against copies of the dev db, basho 202605 (not finalized, day 1 imported, 2250 existing result rows), entering 5 day-1 winners for a player who had no picks:

before after
basho_result rows 2250 2251
that player's row absent wins=5, rank=1
players at rank 1 46 47
award rows 0 0

Also verified a finalized basho is still rejected, and the pre-first-import window: basho_score is a pick-driven view with COALESCE(SUM(win), 0), so running before any torikumi exist writes rows with wins=0, everyone tied at rank 1. That is self-correcting — the first import overwrites it — and the only visible effect is stats.html rendering a 0 instead of a blank winning-score cell for those few hours.

The standings table is only rebuilt when new torikumi are imported, so a player entered mid-basho was missing from the rankings until the next day's results landed. Recompute in the same transaction as the pick replacement.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The transactional recomputation is consistent with the existing torikumi update path and preserves awards and player ranks.

Pull request overview

Recomputes basho standings immediately after administrators enter late picks.

Changes:

  • Recalculates results within the pick-replacement transaction.
  • Updates CLI messaging and reduces default logging noise.
File summaries
File Description
src/enter_picks.rs Updates logging and success messaging.
src/data/basho.rs Recomputes standings after forced pick replacement.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@danieldickison
danieldickison merged commit 4664355 into main Sep 14, 2026
4 checks passed
@danieldickison
danieldickison deleted the enter-picks-recompute-results branch September 14, 2026 04:06
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