diff --git a/backend/services/feed_service.py b/backend/services/feed_service.py index 36fd4b2..0d66f06 100644 --- a/backend/services/feed_service.py +++ b/backend/services/feed_service.py @@ -121,7 +121,7 @@ def _hero_input(now: datetime, slot: str, cur: Optional[WeatherHourly], now_w: O temps = [float(x.row.temp_c) for x in today.slots if x.row] if today else [] rainy = [h for h in now_w.rain_hours if h.rain_type is not RainType.NONE] if now_w else [] return HeroInput( - now=now, night=slot in ("evening", "night"), rain_known=now_w is not None, rain_at=rainy[0].at if rainy else None, + now=now, night=slot in ("evening", "night"), rain_at=rainy[0].at if rainy else None, 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), temp=float(cur.temp_c) if cur else None, feels=float(cur.feels_c) if cur else None, discomfort=cur.discomfort_index if cur else None, diff --git a/backend/services/hero_stats.py b/backend/services/hero_stats.py index 7d95844..318b526 100644 --- a/backend/services/hero_stats.py +++ b/backend/services/hero_stats.py @@ -30,7 +30,6 @@ class HeroInput: now: datetime night: bool rain_at: Optional[datetime] = None - rain_known: bool = False air: Optional[AirGrade] = None uv: Optional[float] = None temp_min: Optional[float] = None @@ -69,9 +68,8 @@ def hero_stats(x: HeroInput) -> list[HeroStatItem]: if x.discomfort is not None and x.discomfort >= MUGGY: alerts.append(HeroStatItem("muggy", "muggy", "불쾌지수", f"{x.discomfort} · {_discomfort_label(x.discomfort)}", "warn")) + # 비는 올 때만 알린다 (안 온다는 칸은 두지 않음) fills: list[HeroStatItem] = [] - if x.rain_known and x.rain_at is None: - fills.append(HeroStatItem("rain", "moon" if x.night else "sun", "2시간 동안 비", "안 와요")) if x.air is not None: fills.append(HeroStatItem("air", "vent", "미세먼지", GRADE_LABEL[x.air])) if not x.night and x.uv is not None: diff --git a/backend/tests/test_hero_stats.py b/backend/tests/test_hero_stats.py index cc32eed..3643b56 100644 --- a/backend/tests/test_hero_stats.py +++ b/backend/tests/test_hero_stats.py @@ -12,23 +12,23 @@ def _view(x: HeroInput) -> list[tuple[str, str, str, str]]: def test_clear_day_shows_uv_warning_and_temp_swing(): - x = HeroInput(now=NOW, night=False, rain_known=True, air=AirGrade.GOOD, uv=6.1, temp_min=13, temp_max=23, temp=23, feels=23, discomfort=68) + x = HeroInput(now=NOW, night=False, air=AirGrade.GOOD, uv=6.1, temp_min=13, temp_max=23, temp=23, feels=23, discomfort=68) assert _view(x) == [("glasses", "자외선", "6 · 높음", "warn"), ("coldwind", "일교차 10°", "아침엔 겉옷", "normal")] def test_rain_comes_first(): - x = HeroInput(now=NOW, night=False, rain_known=True, rain_at=NOW + timedelta(minutes=40), air=AirGrade.GOOD, uv=1.0) + x = HeroInput(now=NOW, night=False, rain_at=NOW + timedelta(minutes=40), air=AirGrade.GOOD, uv=1.0) assert _view(x) == [("umbrella", "지금 비", "오후 3시쯤 와요", "rain"), ("vent", "미세먼지", "좋음", "normal")] def test_bad_air_beats_uv_and_wears_mask(): - x = HeroInput(now=NOW, night=False, rain_known=True, air=AirGrade.VERY_BAD, uv=7.2) + x = HeroInput(now=NOW, night=False, air=AirGrade.VERY_BAD, uv=7.2) assert _view(x) == [("mask", "미세먼지", "매우나쁨", "warn"), ("glasses", "자외선", "7 · 높음", "warn")] -def test_summer_night_muggy_then_no_rain_with_moon_icon(): - x = HeroInput(now=NOW.replace(hour=21), night=True, rain_known=True, uv=0.0, temp=28, feels=31, discomfort=80, moon="보름달") - assert _view(x) == [("muggy", "불쾌지수", "80 · 매우 높음", "warn"), ("moon", "2시간 동안 비", "안 와요", "normal")] +def test_summer_night_muggy_then_moon_and_no_card_for_no_rain(): + x = HeroInput(now=NOW.replace(hour=21), night=True, uv=0.0, temp=28, feels=31, discomfort=80, moon="보름달") + assert _view(x) == [("muggy", "불쾌지수", "80 · 매우 높음", "warn"), ("moon", "오늘 밤 달", "보름달", "normal")] def test_one_coldwind_card_only(): diff --git a/frontend/src/b/TodayPage.tsx b/frontend/src/b/TodayPage.tsx index bf755c5..da4d297 100644 --- a/frontend/src/b/TodayPage.tsx +++ b/frontend/src/b/TodayPage.tsx @@ -208,7 +208,8 @@ function HeroStat({ icon, label, tone = 'normal', children }: { icon: string; la
{label} - {children} + {/* 한국어가 글자 단위로 끊기지 않게 단어 단위로 줄바꿈 */} + {children}
)