- Migration 028 (retroactive): document warehouse columns added to stock_observations - Migration 037: composite indexes for DISTINCT ON (transceiver_id, source_vendor_id) queries - Migration 038: add stock_confidence (1/2/3), price_currency, price_includes_tax, stock_vendor_ts to stock_observations + TRUNCATE test-run data db.ts: upsertStockObservation now accepts stockConfidence, priceCurrency, priceIncludesTax, stockVendorTs; delta detection includes quantity_available fs-com.ts: passes stockConfidence=3 + priceCurrency=EUR + priceIncludesTax=false qsfptek.ts v2: Phase 1 API listing + Phase 2 detail-page stock extraction - Parses 'X in real-time stock, DATE' from product detail pages - Writes stock_observations with confidence=2 + stockVendorTs - Up to 500 detail pages/run at 2s rate limit naddod.ts v2: complete rewrite from WooCommerce to Astro sitemap-based - Discovers products via /sitemaps/products.xml (600+ products) - URL format: /products/XXXXX.html - Extracts 'In Stock: X' exact counts from SSR HTML - Writes both price + stock observations (confidence 1 or 2)
13 lines
577 B
SQL
13 lines
577 B
SQL
-- Migration 037: Add composite indexes for stock_observations
|
|
-- Optimises DISTINCT ON (transceiver_id, source_vendor_id) queries used
|
|
-- by GET /api/stock and GET /api/stock/summary.
|
|
|
|
-- Primary lookup index for "latest per (transceiver, vendor)" queries
|
|
CREATE INDEX IF NOT EXISTS idx_stock_tx_vendor_time
|
|
ON stock_observations (transceiver_id, source_vendor_id, time DESC);
|
|
|
|
-- Partial index for "in-stock only" filter (used by /api/stock?in_stock=true)
|
|
CREATE INDEX IF NOT EXISTS idx_stock_in_stock
|
|
ON stock_observations (in_stock, time DESC)
|
|
WHERE in_stock = true;
|