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:
Kelly
2025-12-14 03:35:25 -07:00
parent f48a503e82
commit f5cb17e1d4
5 changed files with 36 additions and 15 deletions

View File

@@ -213,7 +213,16 @@ router.get('/schedules', async (req: Request, res: Response) => {
try { try {
const enabledOnly = req.query.enabled === 'true'; 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, 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.priority, ts.state_code, ts.pool_id, tp.display_name as pool_name,
ts.platform, ts.method, ts.platform, ts.method,
@@ -223,6 +232,18 @@ router.get('/schedules', async (req: Request, res: Response) => {
FROM task_schedules ts FROM task_schedules ts
LEFT JOIN task_pools tp ON tp.id = ts.pool_id 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) { if (enabledOnly) {
query += ` WHERE ts.enabled = true`; query += ` WHERE ts.enabled = true`;

View File

@@ -140,7 +140,7 @@ async function main() {
console.log('└─────────────────────────────────────────────────────────────┘'); console.log('└─────────────────────────────────────────────────────────────┘');
const variables = { const variables = {
includeEnterpriseSpecials: false, includeEnterpriseSpecials: true,
productsFilter: { productsFilter: {
dispensaryId: disp.platform_dispensary_id, dispensaryId: disp.platform_dispensary_id,
pricingType: 'rec', pricingType: 'rec',

View File

@@ -44,7 +44,7 @@ async function fetchProducts(dispensaryId: string, page = 0, perPage = 25): Prom
const session = 'crawlsy-session-' + Date.now(); const session = 'crawlsy-session-' + Date.now();
const variables = { const variables = {
includeEnterpriseSpecials: false, includeEnterpriseSpecials: true,
productsFilter: { productsFilter: {
dispensaryId, dispensaryId,
pricingType: 'rec', pricingType: 'rec',

View File

@@ -59,7 +59,7 @@ async function main() {
} }
const variables = { const variables = {
includeEnterpriseSpecials: false, includeEnterpriseSpecials: true,
productsFilter: filter, productsFilter: filter,
page: 0, page: 0,
perPage: 100, perPage: 100,

View File

@@ -255,11 +255,11 @@ export async function handleProductDiscoveryDutchie(ctx: TaskContext): Promise<T
try { try {
while (pageNum < 30) { // Max 30 pages = 3000 products while (pageNum < 30) { // Max 30 pages = 3000 products
const variables = { const variables = {
includeEnterpriseSpecials: false, includeEnterpriseSpecials: true, // Include BOGO/sale special names in product data
productsFilter: { productsFilter: {
dispensaryId: platformId, dispensaryId: platformId,
pricingType: 'rec', pricingType: 'rec',
Status: 'Active', // CRITICAL: Must be 'Active', not null Status: 'All', // 'All' = Active + Inactive products for sellout tracking
types: [], types: [],
useCache: true, useCache: true,
isDefaultSort: true, isDefaultSort: true,