Skip to content

fix(insights): CSV export is silently capped at ~1000 rows (all-time export is incomplete) #192

Closed
gitbasitmalik/ansvisor
#1

Description

@gkhngyk

Summary

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:

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):

  1. 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.
  2. 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.
  3. 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.

Activity

  1. added
    bug
    good first issue
    on Jun 8, 2026
  2. gitbasitmalik commented on Jun 9, 2026

    @gitbasitmalik
    Contributor

    Hi @gkhngyk ! I'm a software engineering student and would love to claim this issue.

  3. gkhngyk commented on Jun 15, 2026

    @gkhngyk
    ContributorAuthor

    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!

  4. gkhngyk commented on Jun 16, 2026

    @gkhngyk
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buggood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions