From 72301e9f10d419ecdeede1413e73d6e2ab0395d9 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Mon, 12 Oct 2026 16:24:58 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=9E=88=EC=96=B4=EB=A1=9C=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=ED=95=9C=20=EC=A4=84=20=EC=9E=90=EC=99=B8=EC=84=A0?= =?UTF-8?q?=EC=9D=84=20=EC=A0=80=EB=85=81=20=EA=B5=AC=EA=B0=84(=EC=9D=BC?= =?UTF-8?q?=EB=AA=B0=202=EC=8B=9C=EA=B0=84=20=EC=A0=84~)=EC=97=90=EB=8F=84?= =?UTF-8?q?=20=EB=B3=B4=EC=9D=B4=EA=B2=8C,=20=EB=B0=A4=20=EA=B5=AC?= =?UTF-8?q?=EA=B0=84=EC=97=90=EB=A7=8C=20=EB=BA=80=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/router/v1/feed/protocol.py | 2 +- backend/services/feed_service.py | 2 +- backend/services/hero_stats.py | 5 +++-- backend/tests/test_hero_stats.py | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/router/v1/feed/protocol.py b/backend/router/v1/feed/protocol.py index d9970f6..29e2ceb 100644 --- a/backend/router/v1/feed/protocol.py +++ b/backend/router/v1/feed/protocol.py @@ -171,7 +171,7 @@ class Hero(WebPacketProtocol): moon_name: Optional[str] = Field(default=None, description="오늘 밤 달 모양: 삭·초승달·상현달·차오르는 달·보름달·기우는 달·하현달·그믐달") moon_pct: Optional[int] = Field(default=None, description="달에서 빛나는 면의 비율 0~100 (모양 그림용, 밝기 아님)") stats: list[HeroStat] = Field(default_factory=list, description="히어로 상황 칸 1개. 지금 챙길 것(비·미세먼지·자외선·일교차·체감) 먼저") - status: list[HeroStat] = Field(default_factory=list, description="히어로 상태 한 줄: 습도·불쾌지수·자외선(낮에만)·미세먼지 단계 이름. tone=warn 이면 조심(앱이 주황 글자로)") + status: list[HeroStat] = Field(default_factory=list, description="히어로 상태 한 줄: 습도·불쾌지수·자외선(밤 구간 빼고)·미세먼지 단계 이름. tone=warn 이면 조심(앱이 주황 글자로)") class BandEvent(WebPacketProtocol): diff --git a/backend/services/feed_service.py b/backend/services/feed_service.py index e8864c1..4a34504 100644 --- a/backend/services/feed_service.py +++ b/backend/services/feed_service.py @@ -138,7 +138,7 @@ def _hero_input( ahead = [x for x in today.slots if x.row and x.at > now] if today else [] later = next((x.at for x in ahead if x.row.rain_type != RainType.NONE.value or x.row.rain_prob >= _HERO_RAIN_PROB), None) return HeroInput( - now=now, night=slot in ("evening", "night"), rain_at=rainy[0].at if rainy else None, + now=now, night=slot in ("evening", "night"), after_dark=slot == "night", rain_at=rainy[0].at if rainy else None, rain_later_at=later, today_known=bool(ahead), air=AirGrade(now_w.air.grade) if now_w and now_w.air and now_w.air.grade is not None else None, uv=uv, temp_min=min(temps, default=None), temp_max=max(temps, default=None), diff --git a/backend/services/hero_stats.py b/backend/services/hero_stats.py index bdac3c6..60ac7cc 100644 --- a/backend/services/hero_stats.py +++ b/backend/services/hero_stats.py @@ -42,6 +42,7 @@ class HeroInput: moon: Optional[str] = None humidity: Optional[int] = None discomfort: Optional[int] = None + after_dark: bool = False # 밤 구간(일몰 1시간 뒤~). night 는 저녁 구간까지 포함한다 _UV_LABELS = ("낮음", "보통", "높음", "매우 높음", "위험") @@ -65,13 +66,13 @@ def humidity_label(h: int) -> str: def hero_status(x: HeroInput) -> list[HeroStatItem]: - """히어로 상태 한 줄: 습도·불쾌지수·자외선(낮에만)·미세먼지를 단계 이름으로. 값이 없는 칸은 뺀다. 조심할 것만 warn.""" + """히어로 상태 한 줄: 습도·불쾌지수·자외선(해 있을 때, 저녁 포함)·미세먼지를 단계 이름으로. 값이 없는 칸은 뺀다. 조심할 것만 warn.""" out: list[HeroStatItem] = [] if x.humidity is not None: out.append(HeroStatItem("humidity", "muggy", "습도", humidity_label(x.humidity))) if x.discomfort is not None: out.append(HeroStatItem("discomfort", "muggy", "불쾌지수", discomfort_label(x.discomfort), "warn" if x.discomfort >= MUGGY_DI else "normal")) - if not x.night and x.uv is not None: + if not x.after_dark and x.uv is not None: out.append(HeroStatItem("uv", "glasses", "자외선", uv_label(x.uv), "warn" if x.uv >= UV_HIGH else "normal")) if x.air is not None: out.append(HeroStatItem("air", "mask", "미세먼지", GRADE_LABEL[x.air], "warn" if x.air in (AirGrade.BAD, AirGrade.VERY_BAD) else "normal")) diff --git a/backend/tests/test_hero_stats.py b/backend/tests/test_hero_stats.py index 70fcc78..043b99b 100644 --- a/backend/tests/test_hero_stats.py +++ b/backend/tests/test_hero_stats.py @@ -60,5 +60,7 @@ def test_status_line_has_four_by_day_and_warns_only_caution(): def test_status_line_drops_uv_at_night_and_missing_values(): - assert _status(HeroInput(now=NOW, night=True, humidity=25, uv=3.0, air=AirGrade.NORMAL)) == [("습도", "건조", "normal"), ("미세먼지", "보통", "normal")] + assert _status(HeroInput(now=NOW, night=True, after_dark=True, humidity=25, uv=3.0, air=AirGrade.NORMAL)) == [("습도", "건조", "normal"), ("미세먼지", "보통", "normal")] + # 저녁 구간(night=True, 아직 해 있음)엔 자외선이 남는다 + assert _status(HeroInput(now=NOW, night=True, uv=0.6)) == [("자외선", "낮음", "normal")] assert _status(HeroInput(now=NOW, night=False)) == []