Fix detection query to include dutchie stores missing platform_id
When onlyUnknown=true and onlyMissingPlatformId=true, the query now uses OR logic instead of AND to include: - Stores with unknown menu_type (new stores needing detection) - Stores with menu_type='dutchie' but no platform_dispensary_id This allows re-detection to: 1. Resolve platform IDs for actual Dutchie stores 2. Reclassify stores that migrated away from Dutchie (e.g. to Curaleaf) Also changed default for onlyMissingPlatformId to true so scheduled detection jobs always attempt to resolve missing platform IDs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -816,11 +816,16 @@ export async function runBulkDetection(options: {
|
||||
params.push(state);
|
||||
}
|
||||
|
||||
if (onlyUnknown) {
|
||||
// Handle the combination of onlyUnknown and onlyMissingPlatformId
|
||||
// If both are set, include: unknown menu_type OR (dutchie without platform_id)
|
||||
if (onlyUnknown && onlyMissingPlatformId) {
|
||||
whereClause += ` AND (
|
||||
(menu_type IS NULL OR menu_type = '' OR menu_type = 'unknown')
|
||||
OR (menu_type = 'dutchie' AND platform_dispensary_id IS NULL)
|
||||
)`;
|
||||
} else if (onlyUnknown) {
|
||||
whereClause += ` AND (menu_type IS NULL OR menu_type = '' OR menu_type = 'unknown')`;
|
||||
}
|
||||
|
||||
if (onlyMissingPlatformId) {
|
||||
} else if (onlyMissingPlatformId) {
|
||||
whereClause += ` AND (menu_type = 'dutchie' AND platform_dispensary_id IS NULL)`;
|
||||
}
|
||||
|
||||
@@ -892,7 +897,8 @@ export async function executeMenuDetectionJob(config: Record<string, any> = {}):
|
||||
}> {
|
||||
const state = config.state || 'AZ';
|
||||
const onlyUnknown = config.onlyUnknown !== false;
|
||||
const onlyMissingPlatformId = config.onlyMissingPlatformId || false;
|
||||
// Default to true - always try to resolve platform IDs for dutchie stores
|
||||
const onlyMissingPlatformId = config.onlyMissingPlatformId !== false;
|
||||
|
||||
console.log(`[MenuDetection] Executing scheduled job for state=${state}...`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user