Repository navigation
fix(shopping): normalize chatgpt-shopping cards — pickParser gains a ChatGPT branch - #408
Merged
Merged
Conversation
…ChatGPT branch ChatGPT Shopping results were captured into prompt_results.shopping_cards but never reached prompt_result_shopping_cards: pickParser had no branch for the platform, so normalizeShoppingCards always returned []. The dashboard therefore only ever showed Copilot cards (#399). - parseChatgptCard: normalizes the { products, tags } wrapper products (shape derived from captured production payloads) — title, offer/url merchant fallbacks, image_urls[0], rating/num_reviews. raw keeps a compact subset: a single ChatGPT product runs to tens of KB and the full original stays on prompt_results.shopping_cards (which is what the backfill script re-derives from). - pickParser matches 'chatgpt-shopping' exactly — plain chatgpt-web never carries cards and keeps its unsupported-platform behavior. - parsePrice: disambiguate thousand/decimal separators. "₺2.699,99" previously parsed as 2.699; now 2699.99 (US/EU/TR conventions all covered, shared by every parser). - 13 new tests (wrapper flatten, field mapping, offer fallbacks, price separator matrix); verified against real captured payloads end to end. Backfill needs no changes — it is platform-agnostic and picks up the new parser: node src/scripts/backfill-shopping-cards.js Fixes #399
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
ChatGPT Shopping results were being captured (
prompt_results.shopping_cardsfills up correctly) but never normalized intoprompt_result_shopping_cards:pickParserinserver/src/lib/shopping-cards.jshad no branch forchatgpt-shopping, sonormalizeShoppingCardsalways returned[]and the Shopping dashboard only ever showed Copilot cards.Changes
parseChatgptCard— normalizes the{ products, tags }wrapper products. The shape was derived from real captured production payloads, not guessed:title,url(+offers[0].urlfallback), formatted price strings,image_urls[0],merchantsstring,rating/num_reviews, provider-flatposition.rawintentionally keeps a compact subset: a single ChatGPT product runs to tens of KB (variants, price_history, specs, analytics metadata), and the full original is already persisted onprompt_results.shopping_cards— which is exactly what the backfill script re-derives from, so nothing is lost.pickParsermatcheschatgpt-shoppingexactly — plainchatgpt-webanswers never carry cards, and the existing "unsupported platform → []" test for it stays green.parsePriceseparator fix (shared by all parsers):"₺2.699,99"previously parsed as2.699— the thousands dot was read as a decimal point. The string branch now disambiguates: when both separators appear the last one is the decimal; a lone separator is decimal only with 1-2 trailing digits. Covers US (1,299.99), EU/TR (2.699,99) and multi-group (1.234.567) conventions.matchCardBrandcompetitor matching.Backfill
No changes needed — the script is platform-agnostic and picks up the new parser. After merge, run once to rebuild history from the already-captured raw cards:
Fixes #399
Type of change
fix— Bug fixfeat— New featurechore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npm test— 112 passing (13 new inshopping-cards.test.js).chatgpt-shoppingresults now produce rows inprompt_result_shopping_cardswithplatform = 'chatgpt-shopping'./dashboard/shoppingshould now show ChatGPT alongside Copilot in the platform filters, with own/competitor matching populated.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdnpm run lintpasses (run fromserver/)npm run format:checkpasses (run fromserver/)npm testpasses (run fromserver/)