feat(orchestrator): Add crawl_enabled filter to stores page
- Backend: Filter stores by crawl_enabled (default: enabled only) - API: Support crawl_enabled param in getOrchestratorStores - UI: Add Enabled/Disabled/All filter toggle buttons - UI: Show crawl status icon in stores table 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -117,12 +117,13 @@ router.get('/states', async (_req: Request, res: Response) => {
|
||||
* Returns list of stores with orchestrator status info
|
||||
* Query params:
|
||||
* - state: Filter by state (e.g., "AZ")
|
||||
* - crawl_enabled: Filter by crawl status (default: true, use "all" to show all, "false" for disabled only)
|
||||
* - limit: Max results (default 100)
|
||||
* - offset: Pagination offset
|
||||
*/
|
||||
router.get('/stores', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const { state, limit = '100', offset = '0' } = req.query;
|
||||
const { state, crawl_enabled, limit = '100', offset = '0' } = req.query;
|
||||
|
||||
let whereClause = 'WHERE 1=1';
|
||||
const params: any[] = [];
|
||||
@@ -134,6 +135,16 @@ router.get('/stores', async (req: Request, res: Response) => {
|
||||
paramIndex++;
|
||||
}
|
||||
|
||||
// Filter by crawl_enabled - defaults to showing only enabled
|
||||
if (crawl_enabled === 'false' || crawl_enabled === '0') {
|
||||
whereClause += ` AND (d.crawl_enabled = false OR d.crawl_enabled IS NULL)`;
|
||||
} else if (crawl_enabled === 'all') {
|
||||
// Show all (no filter)
|
||||
} else {
|
||||
// Default: show only enabled
|
||||
whereClause += ` AND d.crawl_enabled = true`;
|
||||
}
|
||||
|
||||
params.push(parseInt(limit as string, 10), parseInt(offset as string, 10));
|
||||
|
||||
const { rows } = await pool.query(`
|
||||
@@ -145,6 +156,7 @@ router.get('/stores', async (req: Request, res: Response) => {
|
||||
d.menu_type as provider,
|
||||
d.platform_dispensary_id,
|
||||
d.last_crawl_at,
|
||||
d.crawl_enabled,
|
||||
dcp.id as profile_id,
|
||||
dcp.profile_key,
|
||||
COALESCE(dcp.status, dcp.config->>'status', 'legacy') as crawler_status,
|
||||
@@ -187,6 +199,7 @@ router.get('/stores', async (req: Request, res: Response) => {
|
||||
provider_raw: r.provider || null,
|
||||
provider_display: getProviderDisplayName(r.provider),
|
||||
platformDispensaryId: r.platform_dispensary_id,
|
||||
crawlEnabled: r.crawl_enabled ?? false,
|
||||
status: r.crawler_status || (r.platform_dispensary_id ? 'legacy' : 'pending'),
|
||||
profileId: r.profile_id,
|
||||
profileKey: r.profile_key,
|
||||
|
||||
Reference in New Issue
Block a user