Skip to content

Page every report table by five and let each column order it - #168

Merged
juanpabloortizo merged 1 commit into
mainfrom
reports/table-paging
Oct 31, 2026
Merged

juanpabloortizo merged 1 commit into
mainfrom
reports/table-paging

Conversation

@juanpabloortizo

Copy link
Copy Markdown
Collaborator

The report tables listed every row at once (by client, agent, model, channel), the reply log paged 25 at a time and the conversation list 50, and no table could be ordered. A busy period turned the reports into a long scroll.

What changes

  • Every report table pages with the shared TablePager: 5 rows by default, 5/10/25/50 to choose. The pager only appears once a table holds more than five rows.
  • Every column header orders its table (SortHeader, new in components/table-sort.tsx). The first click sorts the way the column reads best (times and amounts high to low, names A to Z); the next reverses it. aria-sort is set on the header.
  • Tables covered: Summary (by client, by channel), Costs (by client, agent, model, and every reply), Conversations, and the team table in the client portal's reports.

API

  • GET /reports/replies takes sort (a key of REPLY_SORTS: date, contact, client, agent, channel, model, served by, duration, tokens, cost) and order. Newest first remains the default; unknown keys fall back to it. The CSV export follows the same order.
  • The conversation list (agency and portal) orders by every column it shows except the ad referral ones; the existing four keys keep working.
  • GET /reports/costs returns totals.estimated_replies for the period. The "Estimated" tile used to count only the replies on the page being read, which a five-row page would have made misleading.

Cleanup: the old prev/next pager (.report-pager, reports.prev, reports.next) is gone; nothing else used it.

Tested

  • tests/test_cost_reports.py, tests/test_report_conversations.py, tests/test_reports.py, tests/test_report_operations.py: 13 passed, including new ordering tests and an injection-shaped sort key.
  • tsc --noEmit and ESLint on the changed files: clean.
  • In the browser against a local database: replies 1–5 of 82 sorted by tokens, conversations sorted by resolution time across pages (6–10 of 15), summary sorted by client, the estimated tile showing the period's 75.

🤖 Generated with Claude Code

The report tables showed every row at once (by client, agent, model and
channel), 25 replies or 50 conversations per page, and none could be
ordered. Every table now pages with the shared pager (5 rows by default,
5/10/25/50 to choose) and orders by any column from its header.

The per-group tables are ordered and paged in the browser. The reply list and
the conversation list are paged by the API, so they are ordered there too:
/reports/replies takes sort and order (REPLY_SORTS) and the conversation list
orders by every column it shows except the ad referral ones. Unknown keys fall
back to newest first, and the CSV export follows the order on screen.

The "Estimated" tile counted the replies on the page being read; the cost
report now returns estimated_replies for the whole period.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juanpabloortizo
juanpabloortizo merged commit e4babdb into main Oct 31, 2026
4 checks passed
@juanpabloortizo
juanpabloortizo deleted the reports/table-paging branch October 31, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants