Fix fieldingstats count computed after limit applied
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m9s

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) <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-04-01 17:40:02 -05:00
parent 16f3f8d8de
commit 67e87a893a

View File

@ -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