From bd65674f3a8a0fd244ad183bdbd74000b8a879d0 Mon Sep 17 00:00:00 2001 From: Kelly Date: Wed, 3 Dec 2025 19:40:22 -0700 Subject: [PATCH] fix(menu-detection): remove non-existent platform_dispensary_id_resolved_at column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The UPDATE query was trying to set a column that doesn't exist in the database schema, causing platform ID resolution to fail silently. Now stores the resolved_at timestamp in provider_detection_data JSONB instead. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CLAUDE.md | 6 ++++++ backend/dist/dutchie-az/routes/index.js | 2 -- backend/dist/dutchie-az/services/menu-detection.js | 2 +- backend/src/dutchie-az/services/menu-detection.ts | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index b874c1da..43bb4609 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -130,6 +130,12 @@ - Do NOT mark a dispensary not_crawlable solely because menu_url is null; only mark not_crawlable if the website crawl fails to find a menu or returns 403/404/invalid. Log the reason in provider_detection_data and crawl_status_reason. - Keep this as the menu discovery job (separate from product crawls); log successes/errors to job_run_logs. Only schedule product crawls for stores with menu_type='dutchie' AND platform_dispensary_id IS NOT NULL. +19) **Preserve all stock statuses (including unknown)** + - Do not filter or drop stock_status values in API/UI; pass through whatever is stored on the latest snapshot/product. Expected values include: in_stock, out_of_stock (if exposed), missing_from_feed, unknown. Only apply filters when explicitly requested by the user. + +20) **Never delete or overwrite historical data** + - Do not delete products/snapshots or overwrite historical records. Always append snapshots for changes (price/stock/qty), and mark missing_from_feed instead of removing records. Historical data must remain intact for analytics. + 18) **Per-location cName and platform_dispensary_id resolution** - For each dispensary, menu_url and cName must be valid for that exact location; no hardcoded defaults and no sharing platform_dispensary_id across locations. - Derive cName from menu_url per store: `/embedded-menu/` or `/dispensary/`. diff --git a/backend/dist/dutchie-az/routes/index.js b/backend/dist/dutchie-az/routes/index.js index 7f770a57..f62a84ea 100644 --- a/backend/dist/dutchie-az/routes/index.js +++ b/backend/dist/dutchie-az/routes/index.js @@ -1154,8 +1154,6 @@ router.get('/monitor/active-jobs', async (_req, res) => { jrl.items_succeeded, jrl.items_failed, jrl.metadata, - jrl.worker_id, - jrl.worker_hostname, js.description as job_description, EXTRACT(EPOCH FROM (NOW() - jrl.started_at)) as duration_seconds FROM job_run_logs jrl diff --git a/backend/dist/dutchie-az/services/menu-detection.js b/backend/dist/dutchie-az/services/menu-detection.js index 8d4e4005..5d27ce41 100644 --- a/backend/dist/dutchie-az/services/menu-detection.js +++ b/backend/dist/dutchie-az/services/menu-detection.js @@ -587,7 +587,6 @@ async function detectAndResolveDispensary(dispensaryId) { UPDATE dispensaries SET menu_type = 'dutchie', platform_dispensary_id = $1, - platform_dispensary_id_resolved_at = NOW(), provider_detection_data = COALESCE(provider_detection_data, '{}'::jsonb) || jsonb_build_object( 'detected_provider', 'dutchie'::text, @@ -595,6 +594,7 @@ async function detectAndResolveDispensary(dispensaryId) { 'detected_at', NOW(), 'cname_extracted', $2::text, 'platform_id_resolved', true, + 'platform_id_resolved_at', NOW(), 'resolution_error', NULL::text, 'not_crawlable', false ), diff --git a/backend/src/dutchie-az/services/menu-detection.ts b/backend/src/dutchie-az/services/menu-detection.ts index 492f9aea..74f32add 100644 --- a/backend/src/dutchie-az/services/menu-detection.ts +++ b/backend/src/dutchie-az/services/menu-detection.ts @@ -714,7 +714,6 @@ export async function detectAndResolveDispensary(dispensaryId: number): Promise< UPDATE dispensaries SET menu_type = 'dutchie', platform_dispensary_id = $1, - platform_dispensary_id_resolved_at = NOW(), provider_detection_data = COALESCE(provider_detection_data, '{}'::jsonb) || jsonb_build_object( 'detected_provider', 'dutchie'::text, @@ -722,6 +721,7 @@ export async function detectAndResolveDispensary(dispensaryId: number): Promise< 'detected_at', NOW(), 'cname_extracted', $2::text, 'platform_id_resolved', true, + 'platform_id_resolved_at', NOW(), 'resolution_error', NULL::text, 'not_crawlable', false ),