fix: restore Hong Kong CoWIN reference curve

This commit is contained in:
2569718930@qq.com
2026-05-28 08:14:27 +08:00
parent 1a7d2a487f
commit 725727d763
6 changed files with 282 additions and 32 deletions
+22 -14
View File
@@ -1214,20 +1214,28 @@ def build_country_network_snapshot(city: str, raw: Dict[str, Any]) -> Dict[str,
}
airport_primary_today_obs = ((raw.get("metar") or {}).get("today_obs") or [])
if airport_primary.get("source_code") == "cowin_obs":
try:
from src.database.runtime_state import OfficialIntradayObservationRepository
repo = OfficialIntradayObservationRepository()
local_now = datetime.now(timezone.utc) + timedelta(seconds=city_offset or 0)
local_date_str = local_now.strftime("%Y-%m-%d")
points = repo.load_points(
source_code="cowin_obs",
station_code=airport_primary.get("station_code") or "6087",
target_date=local_date_str,
)
if points:
airport_primary_today_obs = [{"time": p["time"], "temp": p["temp"]} for p in points]
except Exception:
pass
live_points = raw.get("cowin_today_obs") or []
if live_points:
airport_primary_today_obs = [
{"time": p["time"], "temp": p["temp"]}
for p in live_points
if isinstance(p, dict) and p.get("time") and p.get("temp") is not None
]
if not airport_primary_today_obs:
try:
from src.database.runtime_state import OfficialIntradayObservationRepository
repo = OfficialIntradayObservationRepository()
local_now = datetime.now(timezone.utc) + timedelta(seconds=city_offset or 0)
local_date_str = local_now.strftime("%Y-%m-%d")
points = repo.load_points(
source_code="cowin_obs",
station_code=airport_primary.get("station_code") or "6087",
target_date=local_date_str,
)
if points:
airport_primary_today_obs = [{"time": p["time"], "temp": p["temp"]} for p in points]
except Exception:
pass
return {
"provider_code": provider.provider_code,