Skip to content

Prompts: add a sortable Citations column to the All Prompts table (and CSV export) #529

Closed

Description

@gkhngyk

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:

  1. Migration — extend prompt_visibility_summaries (supabase/migrations/00025_prompt_visibility_summaries.sql) with COALESCE(SUM(pr.citation_count), 0)::bigint AS total_citations. ⚠️ The RETURNS TABLE signature changes, so CREATE OR REPLACE will fail — the migration must DROP FUNCTION public.prompt_visibility_summaries(uuid, timestamptz); first, then re-create it. Keep the existing SECURITY INVOKER, the chatgpt-shopping exclusion (feat(shopping): org-level "Shopping mode" toggle + ChatGPT Shopping platform + Insights isolation #155) and the GRANT EXECUTE. Use the next free migration number at the time you open the PR (currently 00034) and run bash supabase/build-schema.sh so schema.sql stays in sync.
  2. Loader — add totalCitations to PromptVisibilitySummary and map row.total_citations in getPromptVisibilitySummaries (web/src/lib/actions/tracking.ts).
  3. Table — add a sortable Citations column next to Mentions (new 'citations' sort key in AllPromptsSortKey), tooltip mirroring the Mentions one: "Total times your pages were cited in AI answers for this prompt over the last 30 days."
  4. CSV export — add a total_citations_30d column next to total_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, the chatgpt-shopping exclusion and its grants; supabase/schema.sql is regenerated via build-schema.sh.
  • yarn lint, yarn typecheck, yarn format:check pass from web/.

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

  1. added
    enhancement
    help wanted
    on Jul 25, 2026
  2. abdullah91111 commented on Jul 25, 2026

    @abdullah91111
    Contributor

    can i work on this?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions