fix: 피드 캐시를 다음 초단기예보가 나오는 시각(:45)에 끝내 비 반영 각 점수가 늦게 보이지 않게

This commit is contained in:
minaChoi committed 2026-10-13 09:25:26 +09:00
1 parent 8a677a766d
commit 055eec69ef
2 files changed
+15 -3

No files matched your search

+3 -3
View File
@@ -13,7 +13,7 @@ from common.database.db_session_manager import DB_SESSION_MNG
from common.database.model.models import Article, OpenMeteoHourly, Post, Region, WeatherHourly
from common.enums import AirGrade, ArticleCategory, ErrorType, PostType, RainType, RefType, Sky, SkyGrade, SkySituation, SkyType, WarningType
from common.logger import LOG
from common.utils.kma_time import KST, kst_midnight, next_vilage_available, now_kst
from common.utils.kma_time import KST, ULTRA_DELAY, kst_midnight, latest_ultra_base, next_vilage_available, now_kst
from common.utils.text import compass, day_range, hour_label, short_day
from crud.feed_crud import FeedCRUD
from crud.region_crud import RegionCRUD
@@ -152,12 +152,12 @@ def feed_day(now: datetime) -> date:
def feed_ttl_sec(now: datetime, sunset_at: datetime) -> int:
"""다음에 피드가 달라지는 시각까지. 시간대 경계·일몰(노을 카드가 내일 것으로)·03:00·예보·미세먼지 갱신 중 가장 빠른 쪽."""
"""다음에 피드가 달라지는 시각까지. 시간대 경계·일몰(노을 카드가 내일 것으로)·03:00·예보·초단기예보·미세먼지 갱신 중 가장 빠른 쪽."""
day = now.date()
at = lambda d, h: datetime.combine(d, time(h), tzinfo=KST) # noqa: E731
sunset = sunset_at.astimezone(KST)
changes = [at(day, _FEED_DAY_START), at(day, 5), at(day, 11), sunset - timedelta(hours=2), sunset, sunset + NIGHT_AFTER_SUNSET,
at(day + timedelta(days=1), _FEED_DAY_START), next_vilage_available(now)]
at(day + timedelta(days=1), _FEED_DAY_START), next_vilage_available(now), latest_ultra_base(now) + timedelta(hours=1) + ULTRA_DELAY]
air = now.replace(minute=20, second=0, microsecond=0)
changes.append(air if air > now else air + timedelta(hours=1))
nxt = min(c for c in changes if c > now)