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,7 +213,16 @@ router.get('/schedules', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const enabledOnly = req.query.enabled === 'true';
|
||||
|
||||
let query = `
|
||||
// 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,
|
||||
@@ -223,6 +232,18 @@ router.get('/schedules', async (req: Request, res: Response) => {
|
||||
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`;
|
||||
|
||||
@@ -140,7 +140,7 @@ async function main() {
|
||||
console.log('└─────────────────────────────────────────────────────────────┘');
|
||||
|
||||
const variables = {
|
||||
includeEnterpriseSpecials: false,
|
||||
includeEnterpriseSpecials: true,
|
||||
productsFilter: {
|
||||
dispensaryId: disp.platform_dispensary_id,
|
||||
pricingType: 'rec',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -59,7 +59,7 @@ async function main() {
|
||||
}
|
||||
|
||||
const variables = {
|
||||
includeEnterpriseSpecials: false,
|
||||
includeEnterpriseSpecials: true,
|
||||
productsFilter: filter,
|
||||
page: 0,
|
||||
perPage: 100,
|
||||
|
||||
@@ -255,11 +255,11 @@ export async function handleProductDiscoveryDutchie(ctx: TaskContext): Promise<T
|
||||
try {
|
||||
while (pageNum < 30) { // Max 30 pages = 3000 products
|
||||
const variables = {
|
||||
includeEnterpriseSpecials: false,
|
||||
includeEnterpriseSpecials: true, // Include BOGO/sale special names in product data
|
||||
productsFilter: {
|
||||
dispensaryId: platformId,
|
||||
pricingType: 'rec',
|
||||
Status: 'Active', // CRITICAL: Must be 'Active', not null
|
||||
Status: 'All', // 'All' = Active + Inactive products for sellout tracking
|
||||
types: [],
|
||||
useCache: true,
|
||||
isDefaultSort: true,
|
||||
|
||||
Reference in New Issue
Block a user