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 {
|
try {
|
||||||
const enabledOnly = req.query.enabled === 'true';
|
const enabledOnly = req.query.enabled === 'true';
|
||||||
|
|
||||||
let query = `
|
// Check if pool_id column exists (migration 114)
|
||||||
SELECT ts.id, ts.name, ts.role, ts.description, ts.enabled, ts.interval_hours,
|
const colCheck = await pool.query(`
|
||||||
ts.priority, ts.state_code, ts.pool_id, tp.display_name as pool_name,
|
SELECT column_name FROM information_schema.columns
|
||||||
ts.platform, ts.method,
|
WHERE table_name = 'task_schedules' AND column_name = 'pool_id'
|
||||||
COALESCE(ts.is_immutable, false) as is_immutable,
|
`);
|
||||||
ts.last_run_at, ts.next_run_at,
|
const hasPoolId = colCheck.rows.length > 0;
|
||||||
ts.last_task_count, ts.last_error, ts.created_at, ts.updated_at
|
|
||||||
FROM task_schedules ts
|
let query: string;
|
||||||
LEFT JOIN task_pools tp ON tp.id = ts.pool_id
|
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) {
|
if (enabledOnly) {
|
||||||
query += ` WHERE ts.enabled = true`;
|
query += ` WHERE ts.enabled = true`;
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user