From a5b57118638cae47da0749ff45c596fa4f0fe202 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Sun, 5 Apr 2026 07:13:00 +0800 Subject: [PATCH] Remove AI analysis and rank cities by recent DEB performance --- frontend/components/dashboard/CitySidebar.tsx | 21 +- .../components/dashboard/PanelSections.tsx | 30 - .../components/terminal/AnalyticsPanel.tsx | 22 +- frontend/hooks/useDashboardStore.tsx | 99 +-- frontend/lib/dashboard-types.ts | 5 + frontend/lib/i18n.ts | 16 +- ...ackfill_recent_daily_actuals_from_metar.py | 2 +- src/analysis/city_query_service.py | 2 +- src/analysis/deb_algorithm.py | 82 +-- src/data_collection/settlement_sources.py | 10 +- src/data_collection/weather_sources.py | 5 +- src/data_collection/wunderground_sources.py | 595 ------------------ src/utils/config_loader.py | 1 - tests/test_web_observability.py | 2 + tests/test_wunderground_history.py | 44 -- web/analysis_service.py | 19 +- web/routes.py | 74 +++ 17 files changed, 124 insertions(+), 905 deletions(-) delete mode 100644 src/data_collection/wunderground_sources.py delete mode 100644 tests/test_wunderground_history.py diff --git a/frontend/components/dashboard/CitySidebar.tsx b/frontend/components/dashboard/CitySidebar.tsx index 9070215f..2b942bfa 100644 --- a/frontend/components/dashboard/CitySidebar.tsx +++ b/frontend/components/dashboard/CitySidebar.tsx @@ -21,6 +21,10 @@ function toRiskGroup(level?: string): RiskGroupKey { return "other"; } +function toPerformanceGroup(city: CityListItem): RiskGroupKey { + return toRiskGroup(city.deb_recent_tier); +} + function normalizeExpandedGroups( value: unknown, ): Record { @@ -60,11 +64,17 @@ export function CitySidebar() { const sortedCities = useMemo( () => [...store.cities].sort((a, b) => { - const aGroup = toRiskGroup(a.risk_level); - const bGroup = toRiskGroup(b.risk_level); + const aGroup = toPerformanceGroup(a); + const bGroup = toPerformanceGroup(b); + const aHitRate = Number(a.deb_recent_hit_rate ?? -1); + const bHitRate = Number(b.deb_recent_hit_rate ?? -1); + const aSamples = Number(a.deb_recent_sample_count ?? 0); + const bSamples = Number(b.deb_recent_sample_count ?? 0); return ( (riskOrder[aGroup] ?? 3) - (riskOrder[bGroup] ?? 3) || + bHitRate - aHitRate || + bSamples - aSamples || a.display_name.localeCompare(b.display_name) ); }), @@ -79,7 +89,7 @@ export function CitySidebar() { other: [], }; sortedCities.forEach((city) => { - groups[toRiskGroup(city.risk_level)].push(city); + groups[toPerformanceGroup(city)].push(city); }); return groups; }, [sortedCities]); @@ -88,7 +98,7 @@ export function CitySidebar() { if (!selectedCity) return; const selected = store.cities.find((city) => city.name === selectedCity); if (!selected) return; - const groupKey = toRiskGroup(selected.risk_level); + const groupKey = toPerformanceGroup(selected); setExpandedGroups((current) => current[groupKey] ? current : { ...current, [groupKey]: true }, ); @@ -200,6 +210,7 @@ export function CitySidebar() { const deviationSeverity = snapshot?.deviation_monitor?.severity || "normal"; const secondaryText = deviationText || peakTempText; + const performanceTier = toPerformanceGroup(city); return (