From e344fae75fc17fa4e7c6f0982a005da0adf4b071 Mon Sep 17 00:00:00 2001 From: AmandaloveYang <2569718930@qq.com> Date: Mon, 11 May 2026 17:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E5=B0=94/=E9=87=9C=E5=B1=B1=20AMOS=20?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BC=93=E5=AD=98=20TTL=20=E4=BB=8E=20300s?= =?UTF-8?q?=20=E9=99=8D=E8=87=B3=2060s=EF=BC=8C=E5=AF=B9=E9=BD=90=E5=AE=98?= =?UTF-8?q?=E7=BD=91=201=20=E5=88=86=E9=92=9F=E5=88=B7=E6=96=B0=E9=A2=91?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- src/data_collection/amos_station_sources.py | 2 -- web/analysis_service.py | 13 +++++++++++-- web/core.py | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) 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,