Commit Graph

414 Commits

Author SHA1 Message Date
cal
3d0c99b183 Merge branch 'main' into issue/142-feat-add-limit-pagination-to-cardpositions-endpoin 2026-03-25 14:52:34 +00:00
cal
eefd4afa37 Merge pull request 'feat: add GET /api/v2/refractor/cards list endpoint (#172)' (#173) from issue/172-feat-add-get-api-v2-refractor-cards-list-endpoint into main 2026-03-25 14:52:24 +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
de9b511ae9 Merge pull request 'test: refractor system Tier 3 test coverage' (#171) from test/refractor-tier3 into main
All checks were successful
Build Docker Image / build (push) Successful in 8m11s
2026-03-25 04:13:17 +00:00
Cal Corum
906d6e575a test: add Tier 3 refractor test cases (T3-1, T3-6, T3-7, T3-8)
Adds four Tier 3 (medium-priority) test cases to the existing refractor test
suite.  All tests use SQLite in-memory databases and run without a PostgreSQL
connection.

T3-1 (test_refractor_track_api.py): Two tests verifying that
  GET /api/v2/refractor/tracks?card_type= returns 200 with count=0 for both
  an unrecognised card_type value ('foo') and an empty string, rather than
  a 4xx/5xx.  A full SQLite-backed TestClient is added to the track API test
  module for these cases.

T3-6 (test_refractor_state_api.py): Verifies that
  GET /api/v2/refractor/cards/{card_id} returns last_evaluated_at: null (not
  a crash or missing key) when the RefractorCardState was initialised but
  never evaluated.  Adds the SQLite test infrastructure (models, fixtures,
  helper factories, TestClient) to the state API test module.

T3-7 (test_refractor_evaluator.py): Two tests covering fully_evolved/tier
  mismatch correction.  When the database has fully_evolved=True but
  current_tier=3 (corruption), evaluate_card must re-derive fully_evolved
  from the freshly-computed tier (False for tier 3, True for tier 4).

T3-8 (test_refractor_evaluator.py): Two tests confirming per-team stat
  isolation.  A player with BattingSeasonStats on two different teams must
  have each team's RefractorCardState reflect only that team's stats — not
  a combined total.  Covers both same-season and multi-season scenarios.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 21:38:25 -05:00
cal
74284fe5a3 Merge pull request 'test: refractor system Tier 1+2 test coverage' (#170) from test/refractor-tier1-tier2 into main 2026-03-24 21:18:13 +00:00
Cal Corum
569dc53c00 test: add Tier 1 and Tier 2 refractor system test cases
Implements all gap tests identified in the PO review for the refractor
card progression system (Phase 1 foundation).

TIER 1 (critical):
- T1-1: Negative singles guard in compute_batter_value — documents that
  hits=1, doubles=1, triples=1 produces singles=-1 and flows through
  unclamped (value=8.0, not 10.0)
- T1-2: SP tier boundary precision with floats — outs=29 (IP=9.666) stays
  T0, outs=30 (IP=10.0) promotes to T1; also covers T2 float boundary
- T1-3: evaluate-game with non-existent game_id returns 200 with empty results
- T1-4: Seed threshold ordering + positivity invariant (t1<t2<t3<t4, all >0)

TIER 2 (high):
- T2-1: fully_evolved=True persists when stats are zeroed or drop below
  previous tier — no-regression applies to both tier and fully_evolved flag
- T2-2: Parametrized edge cases for _determine_card_type: DH, C, 2B, empty
  string, None, and compound "SP/RP" (resolves to "sp", SP checked first)
- T2-3: evaluate-game with zero StratPlay rows returns empty batch result
- T2-4: GET /teams/{id}/refractors with valid team and zero states is empty
- T2-5: GET /teams/99999/refractors documents 200+empty (no team existence check)
- T2-6: POST /cards/{id}/evaluate with zero season stats stays at T0 value=0.0
- T2-9: Per-player error isolation — patches source module so router's local
  from-import picks up the patched version; one failure, one success = evaluated=1
- T2-10: Each card_type has exactly one RefractorTrack after seeding

All 101 tests pass (15 PostgreSQL-only tests skip without POSTGRES_HOST).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 09:02:30 -05:00
cal
bc6c23ef2e Merge pull request 'feat: capture total_count before limit across all paginated endpoints' (#169) from enhancement/total-count-pagination into main
All checks were successful
Build Docker Image / build (push) Successful in 8m22s
2026-03-24 12:45:53 +00: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
a3ca22b277 Merge pull request 'feat: add limit/pagination to notifications endpoint (#140)' (#150) from issue/140-feat-add-limit-pagination-to-notifications-endpoin into main 2026-03-24 12:13:06 +00: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
b14907d018 Merge pull request 'feat: add limit/pagination to gauntletrewards endpoint (#145)' (#165) from issue/145-feat-add-limit-pagination-to-gauntletrewards-endpo into main 2026-03-24 12:12:32 +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
f2ff85556a Merge pull request 'feat: add limit/pagination to pitstats endpoint (#134)' (#158) from issue/134-feat-add-limit-pagination-to-pitstats-endpoint into main 2026-03-24 12:10:59 +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
11794d8c2a Merge pull request 'feat: add limit/pagination to rewards endpoint (#139)' (#152) from issue/139-feat-add-limit-pagination-to-rewards-endpoint into main 2026-03-24 12:09:58 +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
f2e10bcf2f Merge pull request 'feat: add limit/pagination to events endpoint (#147)' (#156) from issue/147-feat-add-limit-pagination-to-events-endpoint into main 2026-03-24 12:09:45 +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
c1a8808cd3 Merge pull request 'feat: add limit/pagination to pitchingcardratings endpoint (#136)' (#161) from issue/136-feat-add-limit-pagination-to-pitchingcardratings-e into main 2026-03-24 12:08:43 +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
6037d3b53f Merge pull request 'feat: add limit/pagination to stratgame (games) endpoint (#138)' (#164) from issue/138-feat-add-limit-pagination-to-stratgame-games-endpo into main 2026-03-24 12:08:14 +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
da21e83f0f Merge pull request 'feat: add limit/pagination to results endpoint (#137)' (#163) from issue/137-feat-add-limit-pagination-to-results-endpoint into main 2026-03-24 12:08:00 +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
849d14a1ec Merge pull request 'feat: add limit/pagination to awards endpoint (#132)' (#157) from issue/132-feat-add-limit-pagination-to-awards-endpoint into main 2026-03-24 12:07:29 +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