Skip to content

chore(seed): populate raw prompt_results.shopping_cards for the demo Shopping page - #232

Merged
gkhngyk merged 2 commits into
mainfrom
chore/seed-shopping-cards
Jun 11, 2026
Merged

gkhngyk merged 2 commits into
mainfrom
chore/seed-shopping-cards

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Closes #153

Context

Most of #153 was already delivered by #176, which seeded the normalized prompt_result_shopping_cards table — so the demo Shopping page's Products surfaced, Shopping SoV, Top merchant KPIs and the 30-day trend chart already populate.

What was still missing is the issue's Part 1: the raw prompt_results.shopping_cards column. The seed left it at the default '[]' for every row, and two surfaces read that column directly (verified in web/src/lib/actions/shopping.ts):

  • Shopping card rate KPI — cardBearingResults / totalResults, filtering shopping_cards != '[]'
  • Per-platform card rate bar chart — counts rows where shopping_cards is a non-empty array

Both showed 0% on the demo because no seeded row had a non-empty shopping_cards.

Change

Add shopping_cards to the prompt_results insert and set it via a CASE to provider-shape JSON on exactly the rows the normalized cards reference (prompt …801), so the raw and normalized layers stay consistent:

prompt_results row cards shape
Perplexity · US Acme (own) + Demo Coffee Co + Fixture Roasters snake_case (image_url, review_count)
Perplexity · GB Acme (own) + Sample Beans snake_case
Google AI Mode · US Acme (own) camelCase (imageUrl, reviewCount)
Copilot · US Acme (own) camelCase

Every other row stays '[]'. Same product titles / prices / merchant domains as the normalized rows #176 seeded; reuses the existing Acme Coffee / Demo Coffee Co / Fixture Roasters / Sample Beans fixture brands (no real names).

shopping.ts only checks these for non-emptiness — the analytics read the normalized table — so the raw shape is for fidelity, but it's kept provider-accurate on purpose.

Verification

Reviewer note: I couldn't run npx supabase db reset here (no local Postgres). Please confirm the reset reloads cleanly and that, signed in as [email protected], the Shopping card rate KPI and the platform bar chart now show non-zero values.

Scope note

Currencies are kept USD to match the already-seeded normalized rows (the issue's "vary currencies" suggestion predates #176; diverging here would desync the two layers). No production code, no migration — fixture only.

gkhngyk added 2 commits June 11, 2026 17:07
The Shopping page's card-rate KPI and the per-platform card-rate bar chart
read prompt_results.shopping_cards, which the seed left at the default '[]'
for every row — so both showed 0% on the demo dashboard. (#176 already
seeded the normalized prompt_result_shopping_cards table, which drives the
other KPIs and the trend chart.)

Set shopping_cards to provider-shape JSON on the exact prompt_results rows
the normalized cards reference (prompt 801: Perplexity US/GB, Google AI Mode
US, Copilot US), so the raw and normalized layers agree:
  - Perplexity -> snake_case (image_url, review_count, ...)
  - Google AI Mode / Copilot -> camelCase (imageUrl, reviewCount, ...)
Same products/prices/merchants as the normalized rows; everything else
stays '[]'. Reuses the existing Acme/Demo/Fixture/Sample fixture brands.
@gkhngyk
gkhngyk merged commit a15f264 into main Jun 11, 2026
2 checks passed
@gkhngyk
gkhngyk deleted the chore/seed-shopping-cards branch June 11, 2026 16:38
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.

chore(seed): add shopping cards fixture so the demo Shopping page isn't empty

1 participant