feat: target rating calculator (#2) #17

Merged
shcizo merged 3 commits from feat/target-rating-calculator-2 into main 2026-05-22 15:46:08 +02:00
Owner

Summary

  • Adds a per-row target rating calculator: enter desired predicted rating + number of rounds, get the required round average computed via binary search over calculatePredictedRating() (reuses the existing PDGA-faithful forward function).
  • Modal opens from a new bullseye icon in col-actions. Vanilla fetch, no HTMX — mirrors the showDebugInfo pattern.
  • If the player has no round_history (graph data and round-level data are separate tables), the modal now shows a "Refresh round history & calculate" button that triggers the existing refresh endpoint and re-runs the calculation on success. Handles the 24h rate-limit and other refresh errors explicitly.
  • Shows a sensitivity bracket (required-1, required, required+1 → predicted) so the user can see how sharp the requirement is.

Closes #2

Test plan

  • Happy path: open modal, submit valid target + rounds, verify result + sensitivity rows
  • Validation: target outside [400, 1200] or rounds outside [1, 20] → modal-level error (no network call)
  • Unreachable target (e.g. 1100 for a ~900-rated player with 4 rounds) → warning fires
  • Target equals current predicted → required ≈ current predicted, no warning
  • Player with no round_history → "Refresh round history & calculate" prompt → click → loading → calculation runs and predicted cell updates
  • Refresh rate-limit (click again immediately after success) → "Try again in N hour(s)"
  • Sensitivity boundary: required converging to 400 or 1200 → lower/upper clamp inside [400, 1200]
  • Regressions: refresh icon, chevron, debug-info still work; clicking bullseye does not expand the row
## Summary - Adds a per-row target rating calculator: enter desired predicted rating + number of rounds, get the required round average computed via binary search over `calculatePredictedRating()` (reuses the existing PDGA-faithful forward function). - Modal opens from a new bullseye icon in `col-actions`. Vanilla fetch, no HTMX — mirrors the `showDebugInfo` pattern. - If the player has no `round_history` (graph data and round-level data are separate tables), the modal now shows a "Refresh round history & calculate" button that triggers the existing refresh endpoint and re-runs the calculation on success. Handles the 24h rate-limit and other refresh errors explicitly. - Shows a sensitivity bracket (`required-1`, `required`, `required+1` → predicted) so the user can see how sharp the requirement is. Closes #2 ## Test plan - [ ] Happy path: open modal, submit valid target + rounds, verify result + sensitivity rows - [ ] Validation: target outside [400, 1200] or rounds outside [1, 20] → modal-level error (no network call) - [ ] Unreachable target (e.g. 1100 for a ~900-rated player with 4 rounds) → warning fires - [ ] Target equals current predicted → required ≈ current predicted, no warning - [ ] Player with no round_history → "Refresh round history & calculate" prompt → click → loading → calculation runs and predicted cell updates - [ ] Refresh rate-limit (click again immediately after success) → "Try again in N hour(s)" - [ ] Sensitivity boundary: required converging to 400 or 1200 → lower/upper clamp inside [400, 1200] - [ ] Regressions: refresh icon, chevron, debug-info still work; clicking bullseye does not expand the row
shcizo added 3 commits 2026-05-22 13:46:51 +02:00
When a player has rating_history (graph) but no round_history (per-round
detail), calculating a target produced a dead-end error. Now the modal
detects the NO_ROUNDS case and shows a button that triggers the existing
refresh-round-history endpoint and re-runs the calculation on success.
Handles the 24h rate-limit and other refresh errors explicitly.
After the binary search converges, also simulate predicted rating at
required±1 average. Display the three rows in the modal so the user can
see how sharp the requirement is — e.g. whether averaging 1 point lower
costs them 1 point of predicted rating or 5.
shcizo merged commit 1442396418 into main 2026-05-22 15:46:08 +02:00
shcizo deleted branch feat/target-rating-calculator-2 2026-05-22 15:46:11 +02:00
Sign in to join this conversation.