fieldingstats.get_totalstats: total_count overwritten by post-filter length #101

Open
opened 2026-04-01 22:39:43 +00:00 by cal · 1 comment
Owner

Problem

In app/routers_v3/fieldingstats.py, the get_totalstats endpoint correctly computes total_count = all_stats.count() before pagination, but then overwrites it at the end:

return_stats["count"] = len(return_stats["stats"])

This replaces the total count with the length of the current page (after a post-filter that excludes rows where sum_xch + sum_sbc <= 0).

Expected Behavior

count should either reflect:

  • The total matching rows (before pagination and post-filter), or
  • Be clearly documented as the filtered page count

Notes

Pre-existing behavior — not introduced by PR #99. Low priority.

## Problem In `app/routers_v3/fieldingstats.py`, the `get_totalstats` endpoint correctly computes `total_count = all_stats.count()` before pagination, but then overwrites it at the end: ```python return_stats["count"] = len(return_stats["stats"]) ``` This replaces the total count with the length of the current page (after a post-filter that excludes rows where `sum_xch + sum_sbc <= 0`). ## Expected Behavior `count` should either reflect: - The total matching rows (before pagination and post-filter), or - Be clearly documented as the filtered page count ## Notes Pre-existing behavior — not introduced by PR #99. Low priority.
Claude added the
ai-working
label 2026-04-01 23:00:43 +00:00
Claude added
ai-pr-opened
and removed
ai-working
labels 2026-04-01 23:02:05 +00:00
Collaborator

Fixed in PR #102.

Removed the return_stats["count"] = len(return_stats["stats"]) line that was overwriting the pre-pagination total_count with the post-filter page length. The correct total_count value was already being set at return_stats initialization — the overwrite was just a stray line.

Fixed in PR #102. Removed the `return_stats["count"] = len(return_stats["stats"])` line that was overwriting the pre-pagination `total_count` with the post-filter page length. The correct `total_count` value was already being set at `return_stats` initialization — the overwrite was just a stray line.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/major-domo-database#101
No description provided.