From dffc124920848c3d8f0f6c32d14b3509b7d6052b Mon Sep 17 00:00:00 2001 From: Kelly Date: Wed, 10 Dec 2025 23:22:19 -0700 Subject: [PATCH] fix(national): Fix active states count and remove StateBadge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change active_states to count states with crawl_enabled=true dispensaries - Filter all national summary queries by crawl_enabled=true - Remove unused StateBadge from National Dashboard header - StateBadge was showing "Arizona" with no way to change it 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- backend/src/multi-state/state-query-service.ts | 11 ++++++----- cannaiq/src/pages/NationalDashboard.tsx | 2 -- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/backend/src/multi-state/state-query-service.ts b/backend/src/multi-state/state-query-service.ts index 6d355535..013f4d4d 100644 --- a/backend/src/multi-state/state-query-service.ts +++ b/backend/src/multi-state/state-query-service.ts @@ -702,22 +702,23 @@ export class StateQueryService { async getNationalSummary(): Promise { const stateMetrics = await this.getAllStateMetrics(); + // Active states = states with at least one crawl-enabled dispensary const result = await this.pool.query(` SELECT COUNT(DISTINCT s.code) AS total_states, COUNT(DISTINCT CASE WHEN EXISTS ( - SELECT 1 FROM dispensaries d WHERE d.state = s.code AND d.menu_type IS NOT NULL + SELECT 1 FROM dispensaries d WHERE d.state = s.code AND d.crawl_enabled = true ) THEN s.code END) AS active_states, - (SELECT COUNT(*) FROM dispensaries WHERE state IS NOT NULL) AS total_stores, + (SELECT COUNT(*) FROM dispensaries WHERE state IS NOT NULL AND crawl_enabled = true) AS total_stores, (SELECT COUNT(*) FROM store_products sp JOIN dispensaries d ON sp.dispensary_id = d.id - WHERE d.state IS NOT NULL) AS total_products, + WHERE d.state IS NOT NULL AND d.crawl_enabled = true) AS total_products, (SELECT COUNT(DISTINCT brand_id) FROM store_products sp JOIN dispensaries d ON sp.dispensary_id = d.id - WHERE d.state IS NOT NULL AND sp.brand_id IS NOT NULL) AS total_brands, + WHERE d.state IS NOT NULL AND d.crawl_enabled = true AND sp.brand_id IS NOT NULL) AS total_brands, (SELECT AVG(price_rec) FROM store_products sp JOIN dispensaries d ON sp.dispensary_id = d.id - WHERE d.state IS NOT NULL AND sp.price_rec > 0) AS avg_price_national + WHERE d.state IS NOT NULL AND d.crawl_enabled = true AND sp.price_rec > 0) AS avg_price_national FROM states s `); diff --git a/cannaiq/src/pages/NationalDashboard.tsx b/cannaiq/src/pages/NationalDashboard.tsx index 3fedf5b3..81558314 100644 --- a/cannaiq/src/pages/NationalDashboard.tsx +++ b/cannaiq/src/pages/NationalDashboard.tsx @@ -8,7 +8,6 @@ import { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { Layout } from '../components/Layout'; -import { StateBadge } from '../components/StateSelector'; import { useStateStore } from '../store/stateStore'; import { api } from '../lib/api'; import { @@ -286,7 +285,6 @@ export default function NationalDashboard() {

-