清理市场概览残留与 refresh_policy 中的 marketOverview 条目

This commit is contained in:
2569718930@qq.com
2026-05-25 23:06:44 +08:00
parent d1aa3550ba
commit b3aabe61ce
6 changed files with 10 additions and 11 deletions
@@ -21,7 +21,7 @@ export function runTests() {
"MarketOverviewBanner.tsx", "MarketOverviewBanner.tsx",
); );
const dashboardSource = fs.readFileSync(dashboardPath, "utf8"); const dashboardSource = fs.readFileSync(dashboardPath, "utf8");
const source = fs.readFileSync(bannerPath, "utf8"); const source = fs.existsSync(bannerPath) ? fs.readFileSync(bannerPath, "utf8") : "";
assert( assert(
!source.includes("AI Overview") && !source.includes("AI Overview") &&
+7
View File
@@ -170,12 +170,15 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
self.open_meteo_cache_ttl_sec = int( self.open_meteo_cache_ttl_sec = int(
os.getenv("OPEN_METEO_CACHE_TTL_SEC", str(MODEL_CACHE_TTL_SEC)) os.getenv("OPEN_METEO_CACHE_TTL_SEC", str(MODEL_CACHE_TTL_SEC))
) )
self.open_meteo_cache_ttl_sec = min(self.open_meteo_cache_ttl_sec, MODEL_CACHE_TTL_SEC)
self.open_meteo_ensemble_cache_ttl_sec = int( self.open_meteo_ensemble_cache_ttl_sec = int(
os.getenv("OPEN_METEO_ENSEMBLE_CACHE_TTL_SEC", str(MODEL_CACHE_TTL_SEC)) os.getenv("OPEN_METEO_ENSEMBLE_CACHE_TTL_SEC", str(MODEL_CACHE_TTL_SEC))
) )
self.open_meteo_ensemble_cache_ttl_sec = min(self.open_meteo_ensemble_cache_ttl_sec, MODEL_CACHE_TTL_SEC)
self.open_meteo_multi_model_cache_ttl_sec = int( self.open_meteo_multi_model_cache_ttl_sec = int(
os.getenv("OPEN_METEO_MULTI_MODEL_CACHE_TTL_SEC", str(MODEL_CACHE_TTL_SEC)) os.getenv("OPEN_METEO_MULTI_MODEL_CACHE_TTL_SEC", str(MODEL_CACHE_TTL_SEC))
) )
self.open_meteo_multi_model_cache_ttl_sec = min(self.open_meteo_multi_model_cache_ttl_sec, MODEL_CACHE_TTL_SEC)
self.multi_model_cache_version = str( self.multi_model_cache_version = str(
os.getenv("OPEN_METEO_MULTI_MODEL_CACHE_VERSION", "v3") os.getenv("OPEN_METEO_MULTI_MODEL_CACHE_VERSION", "v3")
).strip() or "v3" ).strip() or "v3"
@@ -200,9 +203,11 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
self.metar_cache_ttl_sec = int( self.metar_cache_ttl_sec = int(
os.getenv("METAR_CACHE_TTL_SEC", str(METAR_POLL_TTL_SEC)) os.getenv("METAR_CACHE_TTL_SEC", str(METAR_POLL_TTL_SEC))
) )
self.metar_cache_ttl_sec = min(self.metar_cache_ttl_sec, METAR_POLL_TTL_SEC)
self.metar_fast_cache_ttl_sec = int( self.metar_fast_cache_ttl_sec = int(
os.getenv("METAR_FAST_CACHE_TTL_SEC", str(OBSERVATION_REFRESH_SEC)) os.getenv("METAR_FAST_CACHE_TTL_SEC", str(OBSERVATION_REFRESH_SEC))
) )
self.metar_fast_cache_ttl_sec = min(self.metar_fast_cache_ttl_sec, OBSERVATION_REFRESH_SEC)
self._metar_cache: Dict[str, Dict] = {} self._metar_cache: Dict[str, Dict] = {}
self._metar_cache_lock = threading.Lock() self._metar_cache_lock = threading.Lock()
self.taf_cache_ttl_sec = int( self.taf_cache_ttl_sec = int(
@@ -218,6 +223,7 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
self.settlement_cache_ttl_sec = int( self.settlement_cache_ttl_sec = int(
os.getenv("SETTLEMENT_SOURCE_CACHE_TTL_SEC", str(OBSERVATION_REFRESH_SEC)) os.getenv("SETTLEMENT_SOURCE_CACHE_TTL_SEC", str(OBSERVATION_REFRESH_SEC))
) )
self.settlement_cache_ttl_sec = min(self.settlement_cache_ttl_sec, OBSERVATION_REFRESH_SEC)
self._settlement_cache: Dict[str, Dict] = {} self._settlement_cache: Dict[str, Dict] = {}
self._settlement_cache_lock = threading.Lock() self._settlement_cache_lock = threading.Lock()
self.fmi_cache_ttl_sec = int( self.fmi_cache_ttl_sec = int(
@@ -233,6 +239,7 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
self.hko_obs_cache_ttl_sec = int( self.hko_obs_cache_ttl_sec = int(
os.getenv("HKO_OBS_CACHE_TTL_SEC", str(OBSERVATION_REFRESH_SEC)) os.getenv("HKO_OBS_CACHE_TTL_SEC", str(OBSERVATION_REFRESH_SEC))
) )
self.hko_obs_cache_ttl_sec = min(self.hko_obs_cache_ttl_sec, OBSERVATION_REFRESH_SEC)
self._hko_obs_cache: Dict[str, Dict] = {} self._hko_obs_cache: Dict[str, Dict] = {}
self.madis_cache_ttl_sec = int( self.madis_cache_ttl_sec = int(
os.getenv("MADIS_CACHE_TTL_SEC", "300") # 5 min match update rate os.getenv("MADIS_CACHE_TTL_SEC", "300") # 5 min match update rate
-1
View File
@@ -6,4 +6,3 @@ OBSERVATION_REFRESH_SEC = 60
METAR_POLL_TTL_SEC = 5 * 60 METAR_POLL_TTL_SEC = 5 * 60
SCAN_ROWS_REFRESH_SEC = 5 * 60 SCAN_ROWS_REFRESH_SEC = 5 * 60
MODEL_CACHE_TTL_SEC = 30 * 60 MODEL_CACHE_TTL_SEC = 30 * 60
+1 -5
View File
@@ -1,5 +1,4 @@
from src.utils.refresh_policy import ( from src.utils.refresh_policy import (
MARKET_OVERVIEW_TTL_SEC,
METAR_POLL_TTL_SEC, METAR_POLL_TTL_SEC,
MODEL_CACHE_TTL_SEC, MODEL_CACHE_TTL_SEC,
OBSERVATION_REFRESH_SEC, OBSERVATION_REFRESH_SEC,
@@ -11,23 +10,20 @@ def test_refresh_policy_cadences_are_layered():
assert OBSERVATION_REFRESH_SEC == 60 assert OBSERVATION_REFRESH_SEC == 60
assert METAR_POLL_TTL_SEC == 300 assert METAR_POLL_TTL_SEC == 300
assert SCAN_ROWS_REFRESH_SEC == 300 assert SCAN_ROWS_REFRESH_SEC == 300
assert MARKET_OVERVIEW_TTL_SEC == 600
assert MODEL_CACHE_TTL_SEC == 1800 assert MODEL_CACHE_TTL_SEC == 1800
def test_backend_defaults_use_refresh_policy(): def test_backend_defaults_use_refresh_policy():
import src.data_collection.weather_sources as weather_sources import src.data_collection.weather_sources as weather_sources
import web.services.city_runtime as city_runtime import web.services.city_runtime as city_runtime
import web.services.market_overview_api as market_overview_api
import web.services.scan_ai_config as scan_ai_config import web.services.scan_ai_config as scan_ai_config
assert scan_ai_config.SCAN_TERMINAL_PAYLOAD_TTL_SEC == SCAN_ROWS_REFRESH_SEC assert scan_ai_config.SCAN_TERMINAL_PAYLOAD_TTL_SEC == SCAN_ROWS_REFRESH_SEC
assert city_runtime.CITY_FULL_CACHE_TTL_SEC == OBSERVATION_REFRESH_SEC assert city_runtime.CITY_FULL_CACHE_TTL_SEC == OBSERVATION_REFRESH_SEC
assert city_runtime.CITY_PANEL_CACHE_TTL_SEC == SCAN_ROWS_REFRESH_SEC assert city_runtime.CITY_PANEL_CACHE_TTL_SEC == SCAN_ROWS_REFRESH_SEC
assert city_runtime.CITY_MARKET_CACHE_TTL_SEC == SCAN_ROWS_REFRESH_SEC assert city_runtime.CITY_MARKET_CACHE_TTL_SEC == SCAN_ROWS_REFRESH_SEC
assert market_overview_api.OVERVIEW_CACHE_TTL_SEC == MARKET_OVERVIEW_TTL_SEC
source = weather_sources.WeatherDataCollector() source = weather_sources.WeatherDataCollector({})
assert source.metar_cache_ttl_sec == METAR_POLL_TTL_SEC assert source.metar_cache_ttl_sec == METAR_POLL_TTL_SEC
assert source.hko_obs_cache_ttl_sec == OBSERVATION_REFRESH_SEC assert source.hko_obs_cache_ttl_sec == OBSERVATION_REFRESH_SEC
assert source.settlement_cache_ttl_sec == OBSERVATION_REFRESH_SEC assert source.settlement_cache_ttl_sec == OBSERVATION_REFRESH_SEC
+1 -3
View File
@@ -9,11 +9,9 @@ import time
from datetime import datetime from datetime import datetime
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
from src.utils.refresh_policy import MARKET_OVERVIEW_TTL_SEC
_OVERVIEW_CACHE: Dict[str, Dict[str, Any]] = {} _OVERVIEW_CACHE: Dict[str, Dict[str, Any]] = {}
_OVERVIEW_CACHE_LOCK = threading.Lock() _OVERVIEW_CACHE_LOCK = threading.Lock()
OVERVIEW_CACHE_TTL_SEC = MARKET_OVERVIEW_TTL_SEC OVERVIEW_CACHE_TTL_SEC = 600
def _safe_float(value: Any) -> Optional[float]: def _safe_float(value: Any) -> Optional[float]:
-1
View File
@@ -7,7 +7,6 @@ from typing import Any, Dict
from fastapi import HTTPException, Request from fastapi import HTTPException, Request
from fastapi.concurrency import run_in_threadpool from fastapi.concurrency import run_in_threadpool
from web.services.market_overview_api import build_market_overview_payload
import web.routes as legacy_routes import web.routes as legacy_routes