Commit Graph

276 Commits

Author SHA1 Message Date
Cal Corum
776f1a5302 fix: address PR review findings — rename evolution_tier to refractor_tier
- Rename `evolution_tier` parameter to `refractor_tier` in compute_variant_hash()
  to match the refractor naming convention established in PR #131
- Update hash input dict key accordingly (safe: function is new, no stored hashes)
- Update test docstrings referencing the old parameter name
- Remove redundant parentheses on boost_delta_json TextField declaration

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 11:06:38 -05:00
Cal Corum
4a1251a734 feat: add Refractor Phase 2 foundation — boost functions, schema, tests
Pure functions for computing boosted card ratings when a player
reaches a new Refractor tier. Batter boost applies fixed +0.5 to
four offensive columns per tier; pitcher boost uses a 1.5 TB-budget
priority algorithm. Both preserve the 108-sum invariant.

- Create refractor_boost.py with apply_batter_boost, apply_pitcher_boost,
  and compute_variant_hash (Decimal arithmetic, zero-floor truncation)
- Add RefractorBoostAudit model, Card.variant, BattingCard/PitchingCard
  image_url, RefractorCardState.variant fields to db_engine.py
- Add migration SQL for refractor_card_state.variant column and
  refractor_boost_audit table (JSONB, UNIQUE constraint, transactional)
- 26 unit tests covering 108-sum invariant, deltas, truncation, TB
  accounting, determinism, x-check protection, and variant hash behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 13:39:03 -05:00
Cal Corum
537eabcc4d feat: add evaluated_only filter to GET /api/v2/refractor/cards (#174)
Closes #174

Adds `evaluated_only: bool = Query(default=True)` to `list_card_states()`.
When True (the default), cards with `last_evaluated_at IS NULL` are excluded —
these are placeholder rows created at pack-open time but never run through the
evaluator. At team scale this eliminates ~2739 zero-value rows from the
default response, making the Discord /refractor status command efficient
without any bot-side changes.

Set `evaluated_only=false` to include all rows (admin/pipeline use case).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 17:32:59 -05:00
cal
7e7ff960e2 Merge pull request 'feat: add limit/pagination to paperdex endpoint (#143)' (#167) from issue/143-feat-add-limit-pagination-to-paperdex-endpoint into main
All checks were successful
Build Docker Image / build (push) Successful in 7m53s
2026-03-25 14:52:57 +00:00
cal
2c077d0fd3 Merge branch 'main' into issue/143-feat-add-limit-pagination-to-paperdex-endpoint 2026-03-25 14:52:41 +00:00
cal
3d0c99b183 Merge branch 'main' into issue/142-feat-add-limit-pagination-to-cardpositions-endpoin 2026-03-25 14:52:34 +00:00
Cal Corum
0b5d0b474b feat: add GET /api/v2/refractor/cards list endpoint (#172)
Closes #172

- New GET /api/v2/refractor/cards endpoint in refractor router with
  team_id (required), card_type, tier, season, progress, limit, offset filters
- season filter uses EXISTS subquery against batting/pitching_season_stats
- progress=close filter uses CASE expression to compare current_value
  against next tier threshold (>= 80%)
- LEFT JOIN on Player so deleted players return player_name: null
- Sorting: current_tier DESC, current_value DESC
- count reflects total matching rows before pagination
- Extended _build_card_state_response() with progress_pct (computed) and
  optional player_name; single-card endpoint gains progress_pct automatically
- Added non-unique team_id index on refractor_card_state in db_engine.py
- Migration: 2026-03-25_add_refractor_card_state_team_index.sql
- Removed pre-existing unused RefractorTrack import in evaluate_game (ruff)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 01:35:18 -05:00
Cal Corum
1e21894898 fix: skip total_count query for CSV requests and consolidate rewards.py counts
- Guard total_count with `if not csv` ternary to avoid unnecessary
  COUNT query on CSV export paths (10 files)
- Consolidate rewards.py from 3 COUNT queries to 1 (used for both
  empty-check and response)
- Clean up scout_claims.py double `if limit is not None` block
- Normalize scout_opportunities.py from max(1,...) to max(0,...)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 07:43:14 -05:00
Cal Corum
54dccd1981 feat: capture total_count before limit across all paginated endpoints
Ensures the `count` field in JSON responses reflects total matching
records rather than the page size, consistent with the notifications
endpoint pattern from PR #150.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 07:37:26 -05:00
Cal Corum
8af43273d2 feat: add limit/pagination to cardpositions endpoint (#142)
Closes #142

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 07:31:59 -05:00
cal
268b81aea4 Merge branch 'main' into issue/140-feat-add-limit-pagination-to-notifications-endpoin 2026-03-24 12:12:53 +00:00
cal
ff132564c2 Merge branch 'main' into issue/145-feat-add-limit-pagination-to-gauntletrewards-endpo 2026-03-24 12:12:07 +00:00
cal
66505915a7 fix: capture total_count before applying limit so response count reflects matching records not page size 2026-03-24 12:11:18 +00:00
cal
dbd61a6957 Merge branch 'main' into issue/134-feat-add-limit-pagination-to-pitstats-endpoint 2026-03-24 12:10:37 +00:00
cal
85e8b3f37b Merge branch 'main' into issue/139-feat-add-limit-pagination-to-rewards-endpoint 2026-03-24 12:09:54 +00:00
cal
88c0d0cc13 Merge branch 'main' into issue/134-feat-add-limit-pagination-to-pitstats-endpoint 2026-03-24 12:09:43 +00:00
cal
457189fcd8 Merge branch 'main' into issue/145-feat-add-limit-pagination-to-gauntletrewards-endpo 2026-03-24 12:09:31 +00:00
cal
c64f389d64 Merge branch 'main' into issue/147-feat-add-limit-pagination-to-events-endpoint 2026-03-24 12:09:22 +00:00
cal
67af5cd94a Merge branch 'main' into issue/139-feat-add-limit-pagination-to-rewards-endpoint 2026-03-24 12:08:51 +00:00
cal
15ee0764d6 Merge branch 'main' into issue/134-feat-add-limit-pagination-to-pitstats-endpoint 2026-03-24 12:08:49 +00:00
cal
ed35773dd0 Merge pull request 'feat: add limit/pagination to gauntletruns endpoint (#146)' (#160) from issue/146-feat-add-limit-pagination-to-gauntletruns-endpoint into main 2026-03-24 12:08:47 +00:00
cal
23b95f2d3d Merge branch 'main' into issue/139-feat-add-limit-pagination-to-rewards-endpoint 2026-03-24 12:08:39 +00:00
cal
ae2e7320c5 Merge branch 'main' into issue/147-feat-add-limit-pagination-to-events-endpoint 2026-03-24 12:08:37 +00:00
Cal Corum
e7fcf611da feat: add limit/pagination to gauntletruns endpoint (#146)
Closes #146

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 07:08:37 -05:00
cal
2a1d017aa6 Merge branch 'main' into issue/136-feat-add-limit-pagination-to-pitchingcardratings-e 2026-03-24 12:08:28 +00:00
cal
ac8ec4b283 fix: clamp limit to 0 minimum to prevent negative limit values 2026-03-24 12:08:15 +00:00
cal
ae834692aa Merge branch 'main' into issue/136-feat-add-limit-pagination-to-pitchingcardratings-e 2026-03-24 12:08:13 +00:00
cal
623e93c38a Merge branch 'main' into issue/138-feat-add-limit-pagination-to-stratgame-games-endpo 2026-03-24 12:08:04 +00:00
cal
3bbf364a74 Merge branch 'main' into issue/136-feat-add-limit-pagination-to-pitchingcardratings-e 2026-03-24 12:07:58 +00:00
cal
01482519b5 Merge branch 'main' into issue/134-feat-add-limit-pagination-to-pitstats-endpoint 2026-03-24 12:07:48 +00:00
cal
5d2a78749f Merge branch 'main' into issue/147-feat-add-limit-pagination-to-events-endpoint 2026-03-24 12:07:47 +00:00
cal
556d18f64c Merge branch 'main' into issue/137-feat-add-limit-pagination-to-results-endpoint 2026-03-24 12:07:37 +00:00
cal
11e8fba6c5 Merge pull request 'feat: add limit/pagination to scout_opportunities endpoint (#148)' (#154) from issue/148-feat-add-limit-pagination-to-scout-opportunities-e into main 2026-03-24 12:07:32 +00:00
cal
d470a132e2 Merge branch 'main' into issue/138-feat-add-limit-pagination-to-stratgame-games-endpo 2026-03-24 12:07:22 +00:00
cal
cc98a3b368 Merge branch 'main' into issue/136-feat-add-limit-pagination-to-pitchingcardratings-e 2026-03-24 12:07:18 +00:00
cal
eebef62bc9 Merge branch 'main' into issue/147-feat-add-limit-pagination-to-events-endpoint 2026-03-24 12:07:15 +00:00
cal
a23757bb8e Merge branch 'main' into issue/132-feat-add-limit-pagination-to-awards-endpoint 2026-03-24 12:07:10 +00:00
cal
aeb37c20f2 Merge branch 'main' into issue/148-feat-add-limit-pagination-to-scout-opportunities-e 2026-03-24 12:06:57 +00:00
cal
7ca8e48004 Merge branch 'main' into issue/134-feat-add-limit-pagination-to-pitstats-endpoint 2026-03-24 12:06:55 +00:00
cal
0c7a133906 Merge branch 'main' into issue/145-feat-add-limit-pagination-to-gauntletrewards-endpo 2026-03-24 12:06:54 +00:00
cal
01c7b19137 Merge branch 'main' into issue/137-feat-add-limit-pagination-to-results-endpoint 2026-03-24 12:06:51 +00:00
cal
67bcaa1b9b Merge branch 'main' into issue/136-feat-add-limit-pagination-to-pitchingcardratings-e 2026-03-24 12:06:48 +00:00
cal
77179d3c9c fix: clamp limit lower bound to 1 to prevent silent empty responses
Addresses reviewer feedback: max(0,...) admitted limit=0 which would
silently return no results even when matching records exist.
Changed to max(1,...) consistent with feedback on PRs #149 and #152.
2026-03-24 12:06:37 +00:00
cal
fe4d22f28a Merge branch 'main' into issue/132-feat-add-limit-pagination-to-awards-endpoint 2026-03-24 12:06:35 +00:00
cal
3a65d84682 Merge branch 'main' into issue/141-feat-add-limit-pagination-to-mlbplayers-endpoint 2026-03-24 12:06:30 +00:00
cal
9a8558db3a Merge branch 'main' into issue/136-feat-add-limit-pagination-to-pitchingcardratings-e 2026-03-24 12:06:08 +00:00
cal
dbc473b1b5 Merge branch 'main' into issue/139-feat-add-limit-pagination-to-rewards-endpoint 2026-03-24 12:05:54 +00:00
cal
c34ae56ed1 Merge branch 'main' into issue/134-feat-add-limit-pagination-to-pitstats-endpoint 2026-03-24 12:05:54 +00:00
cal
8f29c34985 Merge branch 'main' into issue/137-feat-add-limit-pagination-to-results-endpoint 2026-03-24 12:05:53 +00:00
cal
e79fe8384f Merge branch 'main' into issue/145-feat-add-limit-pagination-to-gauntletrewards-endpo 2026-03-24 12:05:51 +00:00