Repository navigation
feat(content): filter opportunities by prompt - #854
Merged
Merged
Conversation
Opportunities are generated per prompt, but the Content page could only filter by status, impact, type and text. On larger brands the list runs past 100 opportunities across 20-80 prompts, so finding what to publish for one prompt meant scrolling or guessing search terms (#836). - GET /api/content/brand/:brandId takes prompt_id, and the summary aggregate takes the same filter (content_opportunity_aggregates gains p_prompt_id, migration 00099) so the cards describe the filtered list. - GET /api/content/brand/:brandId/prompts lists the brand's prompts that have opportunities, with counts, paged past PostgREST's 1,000-row cap. - The Content page gets a searchable prompt picker next to the other filters, shown when opportunities span two or more prompts. The pick persists as ?prompt=<id>, is part of Clear, and an id that matches no prompt of the brand is dropped. The brand list route now also checks the caller's access to the brand, like the other content routes. Closes #836
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
Closes #836.
Content opportunities are generated per prompt, but the Content page could only filter them by status, impact, type and free text. On larger brands the list runs past 100 opportunities spread across 20–80 prompts, so answering "what should I publish to show up for this prompt?" meant scrolling or guessing search terms.
Server
GET /api/content/brand/:brandIdacceptsprompt_idas an equality filter.content_opportunity_aggregates. It gains ap_prompt_idparameter (migration00099) so the cards describe the filtered list rather than the whole brand.NULL, so existing callers are unaffected. The migration is already applied to production.GET /api/content/brand/:brandId/promptsreturns the brand's prompts that have opportunities, each with its count, most first. It pages past PostgREST's 1,000-row cap. Opportunities whose prompt was deleted are left out, since there is nothing to name them by.Web
?prompt=<id>, so a filtered view can be linked to.Related issue
Closes #836
Type of change
How to test
/dashboard/contentfor a brand whose opportunities span several prompts. The prompt picker shows "All prompts" in the same weight as the other selects.?prompt=selection is kept. Clear brings the full list back and removes the parameter.Checklist
yarn build,yarn lint(no new warnings) andyarn format:checkpass fromweb/yarn test(854 passed) andyarn lintpass fromserver/00099applied via MCP and committed;supabase/schema.sqlregenerated🤖 Generated with Claude Code