Skip to content

feat(insights): remove the Prompt Results by Topic tree - #477

Merged
gkhngyk merged 1 commit into
mainfrom
feature/remove-insights-results-tree
Jul 18, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/remove-insights-results-tree

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes the "Prompt Results by Topic" tree from the bottom of the Insights page. It was a raw result browser (Topic → Prompt → Platform → runs) left over from before the dedicated Topics / Prompts / prompt-detail pages existed, and its 1500-row prompt_results fetch was the heaviest part of the product's most-visited page.

  • Tree removed: PromptResultsGrouped and its sub-components, handleRefreshPrompt, the results state and its 1500-row fetch, and the now-unused grouping.ts + its tests (page.tsx shrinks by ~560 lines). Individual results stay reachable via Prompts → prompt detail → run → result detail.
  • Filter options re-sourced: the region / AI-model dropdowns previously derived their options from the tree's fetch. A new insights_filter_options RPC (migration 00026 — SECURITY INVOKER, chatgpt-shopping excluded per feat(shopping): org-level "Shopping mode" toggle + ChatGPT Shopping platform + Insights isolation #155) returns the brand's distinct regions and model_used slugs in one DISTINCT scan. The client-side model-family grouping (collapsing model versions into one "ChatGPT" option, comma-joined slugs for applyModelFilter) is unchanged, so the dropdowns offer the same values as before — and are now complete across the brand's whole history rather than limited to the last 1500 rows.
  • Empty states preserved: hasAnyData now falls back to the insights_aggregates summary count (accurate, uncapped) instead of the removed rows; the "No results for the …" state already keyed off summary.totalResults.
  • KPI cards, competitor comparison, trend charts, SoV and CSV export untouched (export does its own fetch).

The migration has been applied to the hosted database.

Related issue

Closes #458

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open /dashboard/insights for a brand with tracking data.
  2. The page renders without the "Prompt Results by Topic" section; KPI cards, competitor comparison, SoV charts and CSV export are unchanged.
  3. The Region and AI Model dropdowns offer the same options as before for the same brand.
  4. In the network tab, the Insights load no longer transfers the 1500-row prompt_results payload.
  5. Individual results remain reachable: Prompts → prompt detail → run → result detail.
  6. Filtered-to-empty periods still show the "No results for the …" state with the "Show all data" reset.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

The tree was a raw result browser superseded by the Topics / Prompts /
prompt-detail pages, and its 1500-row prompt_results fetch was the
heaviest part of the Insights load. The region/platform filter dropdowns,
previously derived from that fetch, now come from a new
insights_filter_options RPC (one DISTINCT scan, shopping excluded), so
they keep offering the same values. hasAnyData / empty states key off the
insights_aggregates summary count instead of the removed rows.
@gkhngyk
gkhngyk merged commit 76138f5 into main Jul 18, 2026
5 checks passed
@gkhngyk
gkhngyk deleted the feature/remove-insights-results-tree branch July 18, 2026 19:09
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.

Insights: remove the Prompt Results by Topic tree (superseded by Topics / Prompts pages)

1 participant