feat: brand list prices on buy-from-brand links (Looks shopping list, wishlist rows, detail) #406
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.52) × (1 − Review Confidence (0.53)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 83% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #406"
general
weight: 0.35
mattmck
Carries brand list prices from ingestion to the "Buy from brand" link (#267 follow-up) and shows them on the Looks shopping list, wishlist/catalog rows, the detail page and the mobile detail screen.
What changed
Ingestion (
lib/product-price.ts)price(decimal string, major units) andcurrency(ISO 4217 ornull) intoexternal_product.normalized_json.Shopifysource) use the lowest price among available variants, or the lowest of all variants when every one is sold out. Zero, non-numeric and absurd prices are ignored.data_source.metadata.currencywhen that is set. Otherwise the connector asks the shop's/meta.jsononce per run, and only when some product has a price. If neither gives a currency it staysnull; USD is never assumed. Job metrics recordstoreCurrency/storeCurrencySource.currencyis kept only when present.price_signis never turned into a currency.npm run backfill:product-price(dry run by default;--write,--source,--no-fetch-currency,--limit,--verbose) re-derives prices fromraw_jsonwith the same helpers. Per source, the currency comes from metadata, then from currencies earlier ingests already stored, then from/meta.json. It never clears a currency already stored on a row.API (
lib/buy-link.ts)selectBuyFromBrandLinkreturns{ url, price?, currency?, priceSeenAt? }, all from the same chosen product (a runner-up's price is never used).buyPrice/buyCurrency/buyPriceSeenAt(shared types). These appear only when both an amount and a valid currency are stored.priceSeenAtisexternal_product.fetched_at.purchasePrice.polishes.tsis unchanged (the fields come throughwithBuyUrls).Web
BuyFromBrandLinktakes an optionalpriceand renders it withIntl.NumberFormatplus a small "as of <date>" hint./polishesshows it on wishlist and catalog rows (not owned rows); the detail page always shows it.Mobile
Docs
docs/schema.sqlcomment fordata_source.metadata.currency.Verification
npm run typecheck,npm run lint(no new warnings), and unit tests all pass: functions 2352 passed, 0 failed (1 skipped); web 649 passed; mobile and shared pass.-
tests/product-price.unit.test.cjs, with fixturetests/fixtures/shopify-price-products.json. It covers several variants, sold-out variants, unpriced variants, a missing currency, a configured currency, the/meta.jsonlookup and failures, MakeupAPI, and the backfill plan/run.- buy-link price tests in
buy-link.unit.test.cjs.- Web
buy-price.test.tsandlooks-detail.test.tsfor per-currency subtotal grouping.- Mobile
buy-price.test.ts.LightsLacquerShopify: 182 of 182 products priced; currencyUSDlearned from/meta.json.localhost:55432; no Azure database touched):- The dry run reported 306 of 306
external_productrows would update (HoloTaco 155, Mooncat 101, Lights Lacquer 50), all 306 priced with a currency. All three stores answered/meta.jsonwith USD.- Those products link 223 shades with a buy URL.
- I then ran
--writelocally; a second dry run reports 0 to update, so the backfill is idempotent.-
GET /api/polishesreturnsbuyPrice/buyCurrency/buyPriceSeenAt(176 of 200 rows on the first page).-
/polishesrows show "Buy from brand ↗ $18.00 as of Feb 14, 2026".- The detail page shows "$13.00 as of Feb 14, 2026" beside the button.
- The Looks shopping list with prices. The dev user owns a match for every look I generated, so the dialog never had missing items. The subtotal and price logic is unit-tested.
- The mobile screen (unit-tested and typechecked only).
- The access-control review found no issues. One optional hardening was noted: the
/meta.jsonfetch follows redirects, the same as the existingproducts.jsonfetch, and only a validated ISO code is ever used.- The docs-sync check found only the mobile README gaps, now fixed.
After deploy
npm run backfill:product-price --workspace=swatchwatch-functions(dry run first) against each environment by hand. Not run against any Azure database in this PR.data_source.metadata.currencyfor a store whose/meta.jsonis blocked.🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Brand list prices and “as of” dates now appear beside purchase links on web and mobile when valid price and currency information is available.
Shopping lists show item prices and subtotals grouped by currency, count items without known prices, and include price details in copied list text. Different currencies are never combined.
* Catalog and purchase-link details now include optional brand price information.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->