Skip to content

fix(prompts): count each keyword once in Similar Topics and retune High Opportunity - #1104

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/prompt-volume-ui
Oct 17, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/prompt-volume-ui

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The web side of #1103's median-based prompt volume: Similar Topics counts each keyword once, and High Opportunity moves to the new scale. Please merge it together with #1103.

Before Now
Similar Topics keyword volume Added once per prompt using the keyword: "seo tools" (110k a month) in 121 prompts read 13.1M The keyword's volume, once: 110k, in 121 prompts
Keyword lookup By the prompt's spelling, so a case variant of the provider's key read 0 Case-insensitive
High Opportunity Prompts From 5k a month; High from 10k From 1,500; High from 3,000
Avg. AI Volume Unrounded ("~632.667" on the demo data once volumes are small) Rounded
"Prompts Analyzed · across N keywords" Keyword slots (3,545 on the live brand) Distinct keywords (515), as Similar Topics counts them

Why the thresholds: with #1103 (median per prompt, 45% AI adoption rate) the median prompt on the largest brand goes from ~4.7k to ~1.6k and p90 from ~41k to ~6.7k. 1,500 and 3,000 keep roughly the same share of prompts on the list (about half), with the top third or so High.

Commits: the first set 500 / 1,000 for #1103's median at 15%. The second scales them to 1,500 / 3,000 after #1103 also raised the rate to 45%.

What changes

  • lib/prompt-volume-clusters.ts
    • A keyword's volume counts once.
    • A prompt that lists a keyword twice counts once.
    • Lookups are case-folded.
    • Each prompt in a cluster carries its own volumes, so "Top Prompt" picks the prompt with the most demand.
    • The comment that said it avoided double counting now matches the code.
  • lib/prompt-volume-opportunity.ts (new): OPPORTUNITY_MIN_VOLUME, OPPORTUNITY_HIGH_VOLUME and opportunityLevel. The Insights card and its tooltip use them.
  • prompts/page.tsx:
    • rounded average;
    • distinct keyword count;
    • the Est. AI Volume footnote says it is the median of the keywords' volumes × the adoption rate.
  • prompts/similar-topics/page.tsx: the header totals say they are across prompts.
  • MCP get_prompt_volumes: the description says total_google_volume is the median of the keyword volumes, not their sum. data.ts's doc and the PromptVolume type say the same.
  • Tests:
    • prompt-volume-clusters.test.ts (new) covers the single count, case and duplicates;
    • prompt-volume-opportunity.test.ts (new) covers the thresholds.

Left as is: the server's topicOpportunityImpact thresholds (50k / 10k), as noted in #1103.

Related issue

None. Goes with #1103.

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. With fix(volumes): estimate prompt volume from the median of its keywords at a 45% AI adoption rate #1103's migration applied, open Prompts → Insights.
    • Avg. AI Volume is a whole number.
    • "across N keywords" counts distinct keywords.
    • High Opportunity Prompts lists prompts from ~1.5k a month, with High from ~3k.
  2. Open Similar Topics (See all). A keyword used by several prompts shows its own monthly volume once, with the prompt count beside it.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): no errors; the 7 warnings are in files this PR does not touch
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run:

  • web: yarn test (857) and yarn build pass.
  • In the browser (demo data with 00154 applied): I checked Insights (KPIs, table, footnote, High Opportunity) and Similar Topics, at 1440px and 1024px, in the light and dark themes.

🤖 Generated with Claude Code

…gh Opportunity

Goes with the median-based prompt volume (fix/prompt-volume-median,
migration 00154).

- Similar Topics added a keyword's volume once for every prompt that used
  it, so "seo tools" (110k a month) in 121 prompts read 13.1M; its
  comment said the opposite. A keyword's volume now counts once, is found
  whatever its case (google_volumes keeps the provider's spelling), and a
  prompt listing it twice counts once. Each prompt in a cluster carries
  its own volumes.
- High Opportunity Prompts listed prompts from 5k and called 10k High,
  which suited the old sum. With the median they are 500 and 1,000
  (lib/prompt-volume-opportunity.ts), keeping about the same share of
  prompts on the list.
- Avg. AI Volume is rounded (it read "632.667"), "across N keywords"
  counts distinct keywords, and the footnote, the Similar Topics totals
  and the MCP get_prompt_volumes description say how the figures are made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk ready for review: the web side of #1103 — Similar Topics counts each keyword's volume once, and High Opportunity moves to 500 / 1,000 for the median-based scale. Please merge together with #1103.

ansvisor#1103 raises the default AI adoption rate from 15% to 45%, which triples
every estimate. The High Opportunity thresholds move with it, from 500
and 1,000 to 1,500 and 3,000, so the list keeps about the same share of
prompts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, approving. On the tree merged with main, #1103 and #1105, web tests pass (857). The 1,500 / 3,000 thresholds fit the applied scale: the median prompt is now 720 and p90 6.7k across all rows.

@gkhngyk
gkhngyk merged commit 0715997 into ansvisor:main Oct 17, 2026
5 checks passed
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.

2 participants