fix(menu-detection): remove non-existent platform_dispensary_id_resolved_at column

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 <noreply@anthropic.com>
This commit is contained in:
Kelly
2025-12-03 19:40:22 -07:00
parent 66e07b2009
commit bd65674f3a
4 changed files with 8 additions and 4 deletions

View File

@@ -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. - 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. - 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** 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. - 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/<cName>` or `/dispensary/<cName>`. - Derive cName from menu_url per store: `/embedded-menu/<cName>` or `/dispensary/<cName>`.

View File

@@ -1154,8 +1154,6 @@ router.get('/monitor/active-jobs', async (_req, res) => {
jrl.items_succeeded, jrl.items_succeeded,
jrl.items_failed, jrl.items_failed,
jrl.metadata, jrl.metadata,
jrl.worker_id,
jrl.worker_hostname,
js.description as job_description, js.description as job_description,
EXTRACT(EPOCH FROM (NOW() - jrl.started_at)) as duration_seconds EXTRACT(EPOCH FROM (NOW() - jrl.started_at)) as duration_seconds
FROM job_run_logs jrl FROM job_run_logs jrl

View File

@@ -587,7 +587,6 @@ async function detectAndResolveDispensary(dispensaryId) {
UPDATE dispensaries SET UPDATE dispensaries SET
menu_type = 'dutchie', menu_type = 'dutchie',
platform_dispensary_id = $1, platform_dispensary_id = $1,
platform_dispensary_id_resolved_at = NOW(),
provider_detection_data = COALESCE(provider_detection_data, '{}'::jsonb) || provider_detection_data = COALESCE(provider_detection_data, '{}'::jsonb) ||
jsonb_build_object( jsonb_build_object(
'detected_provider', 'dutchie'::text, 'detected_provider', 'dutchie'::text,
@@ -595,6 +594,7 @@ async function detectAndResolveDispensary(dispensaryId) {
'detected_at', NOW(), 'detected_at', NOW(),
'cname_extracted', $2::text, 'cname_extracted', $2::text,
'platform_id_resolved', true, 'platform_id_resolved', true,
'platform_id_resolved_at', NOW(),
'resolution_error', NULL::text, 'resolution_error', NULL::text,
'not_crawlable', false 'not_crawlable', false
), ),

View File

@@ -714,7 +714,6 @@ export async function detectAndResolveDispensary(dispensaryId: number): Promise<
UPDATE dispensaries SET UPDATE dispensaries SET
menu_type = 'dutchie', menu_type = 'dutchie',
platform_dispensary_id = $1, platform_dispensary_id = $1,
platform_dispensary_id_resolved_at = NOW(),
provider_detection_data = COALESCE(provider_detection_data, '{}'::jsonb) || provider_detection_data = COALESCE(provider_detection_data, '{}'::jsonb) ||
jsonb_build_object( jsonb_build_object(
'detected_provider', 'dutchie'::text, 'detected_provider', 'dutchie'::text,
@@ -722,6 +721,7 @@ export async function detectAndResolveDispensary(dispensaryId: number): Promise<
'detected_at', NOW(), 'detected_at', NOW(),
'cname_extracted', $2::text, 'cname_extracted', $2::text,
'platform_id_resolved', true, 'platform_id_resolved', true,
'platform_id_resolved_at', NOW(),
'resolution_error', NULL::text, 'resolution_error', NULL::text,
'not_crawlable', false 'not_crawlable', false
), ),