diff --git a/backend/src/routes/tasks.ts b/backend/src/routes/tasks.ts index e688a2f6..e91142bb 100644 --- a/backend/src/routes/tasks.ts +++ b/backend/src/routes/tasks.ts @@ -213,16 +213,37 @@ router.get('/schedules', async (req: Request, res: Response) => { try { const enabledOnly = req.query.enabled === 'true'; - let query = ` - SELECT ts.id, ts.name, ts.role, ts.description, ts.enabled, ts.interval_hours, - ts.priority, ts.state_code, ts.pool_id, tp.display_name as pool_name, - ts.platform, ts.method, - COALESCE(ts.is_immutable, false) as is_immutable, - ts.last_run_at, ts.next_run_at, - ts.last_task_count, ts.last_error, ts.created_at, ts.updated_at - FROM task_schedules ts - LEFT JOIN task_pools tp ON tp.id = ts.pool_id - `; + // Check if pool_id column exists (migration 114) + const colCheck = await pool.query(` + SELECT column_name FROM information_schema.columns + WHERE table_name = 'task_schedules' AND column_name = 'pool_id' + `); + const hasPoolId = colCheck.rows.length > 0; + + let query: string; + if (hasPoolId) { + query = ` + SELECT ts.id, ts.name, ts.role, ts.description, ts.enabled, ts.interval_hours, + ts.priority, ts.state_code, ts.pool_id, tp.display_name as pool_name, + ts.platform, ts.method, + COALESCE(ts.is_immutable, false) as is_immutable, + ts.last_run_at, ts.next_run_at, + ts.last_task_count, ts.last_error, ts.created_at, ts.updated_at + FROM task_schedules ts + LEFT JOIN task_pools tp ON tp.id = ts.pool_id + `; + } else { + // Fallback query without pool_id (migration 114 not yet run) + query = ` + SELECT ts.id, ts.name, ts.role, ts.description, ts.enabled, ts.interval_hours, + ts.priority, ts.state_code, NULL::integer as pool_id, NULL::text as pool_name, + ts.platform, ts.method, + COALESCE(ts.is_immutable, false) as is_immutable, + ts.last_run_at, ts.next_run_at, + ts.last_task_count, ts.last_error, ts.created_at, ts.updated_at + FROM task_schedules ts + `; + } if (enabledOnly) { query += ` WHERE ts.enabled = true`; diff --git a/backend/src/scripts/crawl-single-store.ts b/backend/src/scripts/crawl-single-store.ts index 18769b85..0627e7bc 100644 --- a/backend/src/scripts/crawl-single-store.ts +++ b/backend/src/scripts/crawl-single-store.ts @@ -140,7 +140,7 @@ async function main() { console.log('└─────────────────────────────────────────────────────────────┘'); const variables = { - includeEnterpriseSpecials: false, + includeEnterpriseSpecials: true, productsFilter: { dispensaryId: disp.platform_dispensary_id, pricingType: 'rec', diff --git a/backend/src/scripts/test-dutchie-graphql.ts b/backend/src/scripts/test-dutchie-graphql.ts index a5fc1889..608bc59e 100644 --- a/backend/src/scripts/test-dutchie-graphql.ts +++ b/backend/src/scripts/test-dutchie-graphql.ts @@ -44,7 +44,7 @@ async function fetchProducts(dispensaryId: string, page = 0, perPage = 25): Prom const session = 'crawlsy-session-' + Date.now(); const variables = { - includeEnterpriseSpecials: false, + includeEnterpriseSpecials: true, productsFilter: { dispensaryId, pricingType: 'rec', diff --git a/backend/src/scripts/test-status-filter.ts b/backend/src/scripts/test-status-filter.ts index 6bb11026..70f71536 100644 --- a/backend/src/scripts/test-status-filter.ts +++ b/backend/src/scripts/test-status-filter.ts @@ -59,7 +59,7 @@ async function main() { } const variables = { - includeEnterpriseSpecials: false, + includeEnterpriseSpecials: true, productsFilter: filter, page: 0, perPage: 100, diff --git a/backend/src/tasks/handlers/product-discovery-dutchie.ts b/backend/src/tasks/handlers/product-discovery-dutchie.ts index 9391bbe0..56bdc49e 100644 --- a/backend/src/tasks/handlers/product-discovery-dutchie.ts +++ b/backend/src/tasks/handlers/product-discovery-dutchie.ts @@ -255,11 +255,11 @@ export async function handleProductDiscoveryDutchie(ctx: TaskContext): Promise