Repository navigation
fix(content): show an opportunity's volume as its question's, with its source - #1929
Merged
gkhngyk merged 14 commits intoNov 3, 2026
Merged
Conversation
…s into it
The basket check (CONTENT-004) only caught clusters whose prompts and AI
searches overlapped an existing opportunity by 0.6 or more, and only for
generated ones. The dev database has two open opportunities for "What are
the best coffee subscription services in 2026?" (basket overlap 0.15-0.50),
and "+ New" with a page, a prompt's Suggest content and Action Center tasks
were never checked at all.
An opportunity now also stands for its question (source_data.promptText).
When a new one would answer the question of an open one - the same words
with years, case and punctuation aside, the same prompt, or a shared
cluster - it is added to that one instead of opened:
- opportunity-same-question.js (pure): the question key, the match, which
open one is kept (furthest along, then with work, then score, then age)
and the merge: prompts, AI searches, keywords and cited competitors join,
the stronger measured signal and the higher impact stay, and the merge is
recorded on it (`merged`, the latest 20).
- The generator checks every request but Another angle before any model
call or quota slot; a prompt's or a page's request points at the open
one. Re-opening a done opportunity is skipped while another open one
answers its question.
- Send to Content from a task about one prompt joins the open opportunity
on that question, records the task there once, and says so in the
action's History; a task's own opportunity now carries its question.
- The opportunity page notes what was added ("N more requests for the same
question") and, on an archived duplicate, links the one it went into.
- A one-off merge for the duplicates made before this:
scripts/merge-same-question-opportunities.js <brandId|--all> [--apply],
a dry run by default; it keeps one per question and archives the others
pointing at it (mergedInto). On dev it would merge exactly the pair above.
Help: "No duplicates" in Find content opportunities.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…reakdown shows A merge kept the higher of the two scores but only a measured signal's breakdown, so an Action Center task with a higher priority raised the opportunity's score while its Score breakdown still showed the old components. The score now follows the signal that stays: the incoming one's when it is higher and measured, or when neither is; the higher impact is still kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s source
An opportunity's volume added up its prompts' estimates, and each of those
is the median of short head terms for the prompt's category. Five prompts
on 50k head terms read as 112,500 a month, a 9-word question showed 3,038
against 585 for its closest measured phrase, and the generator and the
brief wrote the sum into their text ("Targeting 12,400/mo volume"). A
same-question merge could also keep a sum frozen months ago (145,000 on
dev). Decided 2026-11-01: the opportunity's volume is its question's.
- question-volume.ts: an opportunity's volume is its question's prompt
estimate, "one of N prompts". A long question (6 words or more) says it
is from head terms and names its related keyword closest to its words
that has Google data, with that keyword's own estimate.
- The opportunity page reads it live for its prompt (getQuestionVolume);
when it can't, it shows the question's volume kept at generation
(source_data.questionVolume), never a group's older sum. The export says
what the volume is of. estAiVolume stays the sum the score's demand
weighs.
- The generator stores questionVolume, and neither it nor the brief puts a
volume figure into the model's instructions.
- MCP get_content_opportunity adds `volume`: range, confidence, source,
date, of_prompts, from_head_terms and closest_phrase.
- The places that showed a volume without its badge get the Estimate badge
and its note: the Prompt Volumes chart's card, the Action Center Affected
tab's Volume column and a topic opportunity's demand. Insights' Google
column is labelled "(head terms)", its tip naming DataForSEO.
Help: How estimated AI search volume works (an opportunity's volume, head
terms), Prompt insights (the column's name).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ning an open opportunity sendActionTask now says whether the task joined the open opportunity on its question (`merged`), so the content send's expected result names it, and a second case covers a task that joined one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…stion volume lib/actions/content.ts imported question-volume-read.ts at the top, and it imports the admin client, which is created at module load and needs the service-role env. Every test that reaches content.ts, even indirectly, failed to load with "supabaseUrl is required" (7 files, 22 tests). getQuestionVolume now imports the reader when it runs, as tracking.ts does for the same reason. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ume-question # Conflicts: # web/messages/en.json
…ume-question # Conflicts: # web/src/lib/mcp/data.ts
Collaborator
Author
|
Merged current main (c9854b5) to clear the conflicts: |
8 of 13 tasks
…eyed by text, not an id A topic_opportunity action keys its prompts entity by the suggestion's text, so taskQuestion() handed that text to the prompts.id and prompt_cluster_members.prompt_id uuid filters and Send to Content failed with 22P02 (500). It now returns null unless the entity_key is a uuid (the pattern validate.js already uses), and such a task opens its own opportunity without a question, as a task about several prompts does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…its own only once An opportunity made without a cluster (Send to Content, a task) never makes the clusters merged into it covered, since loadClusterOpportunities reads only rows with a cluster_id. The same cluster came back every night and was merged into the same opportunity again, adding its times searched again (N, 2N, 3N). A cluster an open opportunity already holds (its cluster_id or one of its related_cluster_ids) now counts as covered by it and points at it, without merging again. The test runs two nights in a row and checks that times searched don't grow on the second. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…count a shared cluster's searches once The one-off merge (planSameQuestionMerges) grouped an "Another angle" opportunity with its original, since both carry the same cluster and prompt, and archived one of them. An opportunity with source_data.alternativeOf is now left out of grouping, and answersSameQuestion (so findSameQuestion too) never matches one: it is asked for on purpose beside its original. mergeOpportunity added up times searched even when both rows held the same cluster, so both baskets were that cluster's and the kept row got 2N searches, written for good by the script. When the incoming row shares a cluster with the target, a query now counts once, at the higher of the two, the same "a cluster already held counts once" rule the nightly path follows.
gkhngyk
approved these changes
Nov 2, 2026
gkhngyk
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An opportunity's volume was the sum of its cluster's head terms. That came out about 5× too high, and it froze in the text: on dev, "What are the best coffee subscription services?" showed 145,000/mo, while the question itself is about 3,000. Now an opportunity's volume is its own question's volume, with its source.
Stacked on #1923 (same-question). Merge that first. With this PR, the pair #1923 merges stops showing the frozen 145,000. Customer priorities plan, P0 item 2; owner decision 2026-11-01.
What changes
The rule lives in
web/src/lib/content/question-volume.ts:getQuestionVolume), with "one of N prompts" beside it.source_data.questionVolumestored at generation.estAiVolumestays as the sum that the score's demand part weighs.Server:
clusterMetricsalso returns the representative question's own volume, which the generator stores asquestionVolume(demo data too).MCP:
get_content_opportunitygains avolumefield:of_prompts,from_head_termsandclosest_phrase.The tool description is updated.
Places without a source badge now use the same source:
Loading:
lib/actions/content.tsimports the volume read only whengetQuestionVolumeruns, aslib/actions/tracking.tsdoes. Pages and tests that loadcontent.tsdon't need the service-role client.Help:
ai-search-volume.mdgets "A content opportunity's volume", and the badge places and column name are updated;prompt-insights.md: the column name;approved-articles.jsonrefreshed.Dev, before → after (open opportunities):
Single-prompt opportunities don't change. Four Acme fixture opportunities with no prompt now show "—".
Left for later:
Related issue
None. Customer priorities plan, P0 item 2.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
question-volumeanduse-opportunity-volume;opportunity-markdownandopportunity-detail;volume-estimateandaffected-tab;action-task-sendanddisplay;opportunity-limits.Checked in the browser at 1024px, light and dark: the opportunity's volume card and the Insights column. The user approved the screens.
Checklist
yarn lintpasses (0 errors; 7 old warnings in files this PR doesn't touch)yarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)Full checks on this branch (bd92548): web 798 files / 8298 tests pass, and
yarn buildpasses. Serverformat:checkand lint are clean, and 353 files / 5000 tests pass (3 skipped).🤖 Generated with Claude Code