Recompute basho results after entering picks - #183
Merged
Merged
Conversation
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.
There was a problem hiding this comment.
🟢 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.
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.
enter-pickswritespickrows but the standings table (basho_result) is only rebuilt byupdate_torikumi, so a straggler entered mid-basho was missing from the rankings until the next day's results were imported.force_save_player_picksnow callsupsert_basho_results(&txn, basho_id, false)in the same transaction as the pick replacement — the same callupdate_torikumimakes. 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: falsemeans theawardtable is untouched, andplayer_rankis left tofinalize_bashowhere it belongs. The web-facingsave_player_picksis 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_LOGdrops towarnbecauseupsert_basho_resultslogs at info and was printing itself right after the [y/N] prompt;RUST_LOG=infostill 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:
basho_resultrowsawardrowsAlso verified a finalized basho is still rejected, and the pre-first-import window:
basho_scoreis a pick-driven view withCOALESCE(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 isstats.htmlrendering a 0 instead of a blank winning-score cell for those few hours.