diff --git a/src/data_collection/amos_station_sources.py b/src/data_collection/amos_station_sources.py index 9d63bf1d..a28fabf6 100644 --- a/src/data_collection/amos_station_sources.py +++ b/src/data_collection/amos_station_sources.py @@ -333,8 +333,6 @@ def _amos_parse_runway_table(text: str) -> dict[str, Any]: class AmosStationSourceMixin: """Mixin that adds AMOS runway-level data fetching to WeatherDataCollector.""" - amos_cache_ttl_sec: int = 300 # 5 minutes - def _amos_get_page(self, icao: str) -> Optional[str]: """Fetch the AMOS page. diff --git a/web/analysis_service.py b/web/analysis_service.py index 3a71cef8..4671617e 100644 --- a/web/analysis_service.py +++ b/web/analysis_service.py @@ -18,6 +18,7 @@ from web.core import ( _cache, CACHE_TTL, CACHE_TTL_ANKARA, + CACHE_TTL_KOREAN_AMOS, CITIES, CITY_RISK_PROFILES, SETTLEMENT_SOURCE_LABELS, @@ -177,8 +178,16 @@ def get_analysis_cache_stats() -> Dict[str, Any]: return stats +KOREAN_AMOS_CITIES = {"seoul", "busan"} + + def _analysis_ttl_for_city(city: str) -> int: - return CACHE_TTL_ANKARA if city.lower() in TURKISH_MGM_CITIES else CACHE_TTL + city_lower = city.lower() + if city_lower in TURKISH_MGM_CITIES: + return CACHE_TTL_ANKARA + if city_lower in KOREAN_AMOS_CITIES: + return CACHE_TTL_KOREAN_AMOS + return CACHE_TTL def _analysis_cache_key(city: str, detail_mode: str = "full") -> str: @@ -1617,7 +1626,7 @@ def _analyze( ) -> Dict[str, Any]: """Fetch, analyse, and return structured weather data for one city.""" # Check cache - ttl = CACHE_TTL_ANKARA if city.lower() in TURKISH_MGM_CITIES else CACHE_TTL + ttl = _analysis_ttl_for_city(city) normalized_detail_mode_raw = str(detail_mode or "full").strip().lower() if normalized_detail_mode_raw == "panel": normalized_detail_mode = "panel" diff --git a/web/core.py b/web/core.py index 2de58e53..742008af 100644 --- a/web/core.py +++ b/web/core.py @@ -86,6 +86,7 @@ SETTLEMENT_SOURCE_LABELS: Dict[str, str] = { _cache: Dict[str, Dict] = {} CACHE_TTL = 300 CACHE_TTL_ANKARA = 60 +CACHE_TTL_KOREAN_AMOS = 60 _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) _PROBABILITY_EVALUATION_REPORT = os.path.join( _PROJECT_ROOT,