Repository navigation
Closed
Labels
Description
Problem
On /dashboard/shopping, product prices render with raw float-precision garbage, e.g. 2999.989990234375 TRY in the Competitors products table.
Two layers contribute:
- Source data carries float32 noise. Cloro's Copilot responses serialize prices like
2999.989990234375(= float32 of2999.99) and2999.39990234375(=2999.40). The card normalizer (server/src/lib/shopping-cards.js,parsePrice) stores the amount as-is, so the noise lands inprompt_result_shopping_cards.price_amount. - The UI does no money formatting.
web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsxrenders the raw value —{p.last_price} {p.price_currency}(~line 1146) and{card.price}in the appearances drawer (~line 705). The CSV export uses the same raw value.
Fix (both layers)
- Normalize: in
parsePrice, round the parsed amount to 2 decimals (Math.round(amount * 100) / 100) so the noise is cut at the source. Add a test case with a float32-noisy input (e.g.2999.989990234375→2999.99). - Display: format prices in the Shopping UI with
Intl.NumberFormat(2 fraction digits, thousands separators) whereverprice_amount/last_priceis shown — product tables, the appearances drawer, and the CSV export can keep the plain 2-decimal number.
Cleanup of existing rows
Existing prompt_result_shopping_cards rows keep the noisy values until re-normalized. The backfill script (server/src/scripts/backfill-shopping-cards.js) is idempotent and re-derives from the raw cards on prompt_results, so one run after the parser change rewrites history — no migration needed. (Ops note: a backfill run is already planned for #399's ChatGPT cards; doing it after this lands cleans both in one pass.)
Acceptance criteria
-
parsePricerounds amounts to 2 decimals (unit test with a float32-noisy input) - Shopping tables/drawer display formatted prices (no
…989990234375anywhere) - CSV export emits at most 2 decimals
- Backfill run re-normalizes existing rows (verified on a brand with Copilot cards)
Activity
[-]bug(shopping): prices render with float-precision garbage (e.g. 2999.989990234375 TRY)[/-][+]bug(shopping): prices render with float-precision garbage [/+]