deckhearth/.convoys/pricing-online-local/brief-3-mtg-bulk-sync-snapshots.md
Randall Stillwell d0468015eb
Some checks failed
CI / Lint (pull_request) Has been cancelled
CI / Schema map up to date (pull_request) Has been cancelled
CI / Forbidden patterns (9 checks) (pull_request) Has been cancelled
CI / Migrations apply (node-pg-migrate) (pull_request) Has been cancelled
Visual diff / Should run? (pull_request) Has been cancelled
CI / Unit tests (vitest) (pull_request) Has been cancelled
Convoy metrics gate / Require role-event telemetry on convoy PRs (pull_request) Has been cancelled
PR Health rollup / Aggregate gate status (pull_request) Has been cancelled
Preview smoke / Should run? (pull_request) Has been cancelled
Preview smoke / Playwright smoke (pull_request) Has been cancelled
Visual diff / Screenshot diff (pull_request) Has been cancelled
feat(pricing): convoy for online prices and local stores
Add pricing schema, free API integrations (MTG bulk, TCGdex, Foolio),
valuation and sort-by-price, card detail pricing UI, and nearby store
discovery via home zip and OSM geo clients.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-08 22:47:46 -05:00

44 lines
1.7 KiB
Markdown

---
convoy: pricing-online-local
brief_number: 3
depends_on: [2]
recommended_model: composer-2.5
model_tier: standard
files:
- lib/card-import/bulk-sync.js
- test/lib/card-import/bulk-sync.test.js
cross_brief_commitments:
- brief: 2
description: |
Uses `recordPriceSnapshots` and sets `prices_updated_at = CURRENT_TIMESTAMP`
on each upsert batch where price columns change.
---
# Brief 3: MTG bulk sync + snapshots
## Goal (1 sentence)
Update Scryfall bulk sync to stamp `prices_updated_at` and record daily price history snapshots.
## Files in scope (do not edit anything else)
- `lib/card-import/bulk-sync.js`
- `test/lib/card-import/bulk-sync.test.js`
## Conventions to follow
- Keep existing `mapCard()` mapping: `usd` → `current_price`, `usd_foil` → `market_price`.
- Add `prices_updated_at` to INSERT/UPDATE columns (set when either price is non-null).
- After each successful `upsertBatch`, call `recordPriceSnapshots` for rows with prices (`source: 'scryfall'`, `priceType: 'market'` for nonfoil amount, optionally second snapshot for foil if present).
- Export `mapCard` for unit tests (or test via named export already present).
- Preserve Scryfall User-Agent header.
## Acceptance criteria
- [ ] `upsertBatch` writes `prices_updated_at`
- [ ] Price snapshots recorded per card per sync day
- [ ] `mapCard` unit tests cover price parsing
- [ ] Existing `runBulkMtgSync` return shape unchanged (add optional `snapshotsWritten` count)
- [ ] Tests pass
- [ ] No scope expansion
## Rationale (≤3 sentences)
MTG already has price data from Scryfall; this brief wires timestamps and history without changing upstream source. Fixes the data pipeline for Phase 1 pricing API reads.