feat(dutchie): Full payload with specials and all product statuses
- Set includeEnterpriseSpecials: true to get BOGO/sale deal names - Set Status: 'All' to capture both Active and Inactive (sold out) products - Make schedules query backward-compatible for missing pool_id column 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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`;
|
||||
|
||||
Reference in New Issue
Block a user