Skip to content

Paginate the cohort builder and add a cohort CSV export - #21

Open
HarisChandio wants to merge 1 commit into
ethanplusai:mainfrom
HarisChandio:cohort-pagination
Open

HarisChandio wants to merge 1 commit into
ethanplusai:mainfrom
HarisChandio:cohort-pagination

Conversation

@HarisChandio

@HarisChandio HarisChandio commented Oct 16, 2026 •

Copy link
Copy Markdown

Problem

The cohort builder on the Signals tab stops at the first 50 matches. The API returns at most 200 companies, the page slices that to 50 and says "Showing the first 50", and there is no way to see the rest. With 147 matches, 97 companies could not be seen anywhere in the dashboard.

Change

  • POST /api/cohort takes offset and limit (default 50, capped at 200). Results are ordered by name, then id, so pages never overlap or skip. size is always the whole cohort. The response keeps the existing size / companies keys, so existing callers still work.
  • GET /api/cohort.csv?require=A,B&exclude=C downloads every company in the cohort (name, domain, website, industry, location).
  • UI: Prev / Next buttons, "Showing 51–100 of 147", and an Export CSV link under the cohort table. Changing a checkbox goes back to page 1, and if the cohort shrinks under the current page it falls back to page 1.
  • The cohort size is now counted up to 10,000 instead of 1,000. Company lookups are chunked to stay under SQLite's 999 bound-variable limit on older builds.

Testing

  • New tests in tests/test_dashboard_signals.py: paging through 120 matches returns all 120 in a stable order with no overlap, the page size is capped, the CSV contains every match rather than one page, and an empty cohort exports only the header.
  • Full suite: 532 passed, 22 skipped.
  • Checked by hand against a real database with 147 matches: page 3 shows 101–147, Next is disabled on the last page, and the CSV downloads 147 rows.

The cohort table on the Signals tab showed only the first 50 matches
(the API returned at most 200) with no way to reach the rest.

- POST /api/cohort takes offset/limit (default 50, max 200), orders by
  name so pages never overlap, and always reports the full size.
- GET /api/cohort.csv exports every company in the cohort.
- The UI gets Prev / Next, "Showing X–Y of N", and an Export CSV link.
- Company lookups are chunked to stay under SQLite's bound-variable cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HarisChandio

Copy link
Copy Markdown
Author

@ethanplusai Hi,
I like what you are building and I am using it for my business.
And I will keep contributing, thanks.

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.

1 participant