Description
Problem
The All Prompts table (web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx) shows a sortable Mentions column but nothing for citations, even though citations are an equal visibility signal everywhere else in the product (a prompt counts as "appeared" when mention_count > 0 OR citation_count > 0). A prompt that is never mentioned but consistently cited — a real win, especially with target-URL tracking now in place — is invisible in this table: sorting by Mentions ranks it at the bottom. The CSV export has the same gap (total_mentions_30d exists, citations don't).
Fix
Four small pieces:
- Migration — extend
prompt_visibility_summaries(supabase/migrations/00025_prompt_visibility_summaries.sql) withCOALESCE(SUM(pr.citation_count), 0)::bigint AS total_citations.⚠️ TheRETURNS TABLEsignature changes, soCREATE OR REPLACEwill fail — the migration mustDROP FUNCTION public.prompt_visibility_summaries(uuid, timestamptz);first, then re-create it. Keep the existingSECURITY INVOKER, thechatgpt-shoppingexclusion (feat(shopping): org-level "Shopping mode" toggle + ChatGPT Shopping platform + Insights isolation #155) and theGRANT EXECUTE. Use the next free migration number at the time you open the PR (currently00034) and runbash supabase/build-schema.shsoschema.sqlstays in sync. - Loader — add
totalCitationstoPromptVisibilitySummaryand maprow.total_citationsingetPromptVisibilitySummaries(web/src/lib/actions/tracking.ts). - Table — add a sortable Citations column next to Mentions (new
'citations'sort key inAllPromptsSortKey), tooltip mirroring the Mentions one: "Total times your pages were cited in AI answers for this prompt over the last 30 days." - CSV export — add a
total_citations_30dcolumn next tototal_mentions_30d.
Acceptance criteria
- The All Prompts table shows a Citations column that sorts ascending/descending like Mentions; prompts without runs render "—".
- CSV export includes
total_citations_30d. - The recreated RPC keeps
SECURITY INVOKER, thechatgpt-shoppingexclusion and its grants;supabase/schema.sqlis regenerated viabuild-schema.sh. yarn lint,yarn typecheck,yarn format:checkpass fromweb/.
Getting started
See CONTRIBUTING.md for setup. The migration is applied to the hosted database by a maintainer after merge — your PR just needs the numbered migration file and the regenerated schema.sql. Comment here to claim the issue before opening a PR.
Activity
abdullah91111 commentedon Jul 25, 2026
can i work on this?