From 2cb83a63f176aa55407018aeaf2276ac69a00915 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sat, 18 Apr 2026 14:49:34 +0200 Subject: [PATCH] docs: catalog population implementation plans (schema migration + ingestion script) --- .../2026-04-18-catalog-ingestion-script.md | 43 +------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/docs/superpowers/plans/2026-04-18-catalog-ingestion-script.md b/docs/superpowers/plans/2026-04-18-catalog-ingestion-script.md index 0c16e30..99c1d3d 100644 --- a/docs/superpowers/plans/2026-04-18-catalog-ingestion-script.md +++ b/docs/superpowers/plans/2026-04-18-catalog-ingestion-script.md @@ -429,48 +429,7 @@ main().catch((err) => { }); ``` -- [ ] **Step 3: Add market prices upsert after the bulk upsert** - -After `upsertItems`, add a call to also upsert `marketPrices` for each item that has a price. This requires knowing the item IDs returned from the bulk upsert and the manufacturer's country/currency. Add this helper after `upsertItems`: - -```typescript -async function upsertMarketPrices( - globalItemIds: number[], - items: CatalogItem[], -): Promise { - for (let i = 0; i < globalItemIds.length; i++) { - const item = items[i]; - const globalItemId = globalItemIds[i]; - if (!item?.priceCents || !globalItemId) continue; - - // Derive market from currency - const market = item.priceCurrency === "EUR" ? "EU" - : item.priceCurrency === "USD" ? "US" - : item.priceCurrency === "GBP" ? "GB" - : item.priceCurrency; - - await fetch(`${GEARBOX_URL}/api/global-items/${globalItemId}/market-prices`, { - method: "POST", - headers: { - "Content-Type": "application/json", - "X-API-Key": GEARBOX_API_KEY, - }, - body: JSON.stringify({ - market, - currency: item.priceCurrency, - priceCents: item.priceCents, - source: "manufacturer-crawl", - }), - }); - } -} -``` - -Call `upsertMarketPrices` in `main()` after the bulk upsert, passing the item IDs from the API response. - -Note: The bulk upsert response returns `items[]` with IDs. Store those and pass them here. Update the `upsertItems` function return type to also return `itemIds: number[]`. - -- [ ] **Step 4: Commit** +- [ ] **Step 3: Commit** ```bash git add scripts/crawl-manufacturer.ts