You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(insights): CSV export is silently capped at ~1000 rows (all-time export is incomplete) #192
On the Answer Engine Insights page (/dashboard/insights), Export CSV
silently exports at most ~1000 rows, even when the date range is All time.
The exported file looks complete but is truncated, with no indication to the
user.
Root cause
The export builds the CSV from the in-memory results array used by the
on-screen "Prompt Results" list, and that list is capped:
results come from getPromptResults in web/src/lib/actions/tracking.ts,
which runs an .order(...) query without .range(). PostgREST returns at
most ~1000 rows by default, so the requested limit of 1500 never actually
arrives and total (derived from the same array) is also capped.
Note: this only affects the raw results list and the CSV. The KPI cards, the
Brand vs Competitors leaderboard, and Share of Voice all come from aggregate
RPCs and are not capped — they already cover the full dataset.
Suggested fix
Add a dedicated export data path that fetches the complete set, server-side,
respecting the currently applied filters (date range, platform, model, region):
New server action (e.g. exportPromptResults(brandId, filters)) that
paginates with .range(from, to) in a loop (page size ~1000) until a page
returns fewer rows than the page size.
Apply a sane hard ceiling (e.g. 50,000 rows) to avoid runaway memory. If the
ceiling is reached, surface it honestly (e.g. a note in the UI / a final CSV
line) rather than truncating silently.
Wire handleExportCsv to call this action (async) instead of reading the
in-memory results, and show a brief loading state on the Export button
while it runs.
Reuse the existing toCsv helper and the current INSIGHT_EXPORT_HEADERS /
row shape — only the data source changes.
Acceptance
Exporting with All time and no filters returns every result for the brand
(up to the ceiling), not ~1000.
Applying filters narrows the export accordingly.
If the ceiling is hit, the user is told the export was capped.
Hi @gitbasitmalik — thanks for offering, and apologies for the slow reply! I've assigned this one to you, it's all yours. 🎉
A couple of pointers to get started:
The cap lives in the Insights CSV export path on the web side; the goal is to stream/paginate so an all-time export isn't silently truncated at ~1000 rows.
See CONTRIBUTING.md for branch naming (fix/) and how to run the app locally.
No rush — feel free to ask here if you get stuck or want to talk through the approach. If things stall for a couple of weeks with no activity we'll reopen it to others, but the floor is yours for now. Looking forward to the PR!
Resolved on main. The Insights CSV export no longer stops at ~1000 rows — exportPromptResults now paginates through the full result set (1000-row pages, up to a 50,000-row safety ceiling that's surfaced via an explicit isCapped flag rather than a silent truncation), and the Insights export path uses it. Landed in #257 — thanks @gitbasitmalik! Closing as fixed.
Activity
gitbasitmalik commentedon Jun 9, 2026
Hi @gkhngyk ! I'm a software engineering student and would love to claim this issue.
gkhngyk commentedon Jun 15, 2026
Hi @gitbasitmalik — thanks for offering, and apologies for the slow reply! I've assigned this one to you, it's all yours. 🎉
A couple of pointers to get started:
fix/) and how to run the app locally.No rush — feel free to ask here if you get stuck or want to talk through the approach. If things stall for a couple of weeks with no activity we'll reopen it to others, but the floor is yours for now. Looking forward to the PR!
fix(web): paginate insights export to bypass 1000-row limit (ansvisor…
fix(web): prevent spurious 'Failed to fetch' toast when switching bra…
gkhngyk commentedon Jun 16, 2026
Resolved on
main. The Insights CSV export no longer stops at ~1000 rows —exportPromptResultsnow paginates through the full result set (1000-row pages, up to a 50,000-row safety ceiling that's surfaced via an explicitisCappedflag rather than a silent truncation), and the Insights export path uses it. Landed in #257 — thanks @gitbasitmalik! Closing as fixed.