From 67e87a893a63d6167bb232d5206c09071e78c246 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Wed, 1 Apr 2026 17:40:02 -0500 Subject: [PATCH] Fix fieldingstats count computed after limit applied Capture total_count before .limit() so the response count reflects all matching rows, not just the capped page size. Resolves #100. Co-Authored-By: Claude Opus 4.6 (1M context) --- app/routers_v3/fieldingstats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/routers_v3/fieldingstats.py b/app/routers_v3/fieldingstats.py index 849cfb2..e892eab 100644 --- a/app/routers_v3/fieldingstats.py +++ b/app/routers_v3/fieldingstats.py @@ -93,13 +93,14 @@ async def get_fieldingstats( ) all_stats = all_stats.where((BattingStat.week >= start) & (BattingStat.week <= end)) + total_count = all_stats.count() all_stats = all_stats.limit(limit) if sort: if sort == "newest": all_stats = all_stats.order_by(-BattingStat.week, -BattingStat.game) return_stats = { - "count": all_stats.count(), + "count": total_count, "stats": [ { "player": x.player_id