fix: 히어로 비 칸은 오늘 하루 기준(곧 와요 / 오후 6시쯤 와요 / 안 와요), 챙길 것 없는 값으로 칸 채우지 않기

- 2시간 안 비는 '지금 비', 그 뒤 오늘 안 비는 '오늘 비 · N시쯤 와요', 없으면 '오늘 비 · 안 와요'
- '미세먼지 좋음'·'자외선 낮음'으로 빈 칸을 채우던 것 삭제 (나쁠 때만 경고로)
- 칸이 하나면 한 줄 전체를 씀
This commit is contained in:
minaChoi committed 2026-10-07 16:33:23 +09:00
1 parent 794e70e419
commit 1af2faa6f4
4 files changed
+22 -9

No files matched your search

+8 -6
View File
@@ -29,7 +29,9 @@ class HeroStatItem:
class HeroInput:
now: datetime
night: bool
rain_at: Optional[datetime] = None
rain_at: Optional[datetime] = None # 앞으로 2시간 안에 비 오는 첫 시각 (초단기)
rain_later_at: Optional[datetime] = None # 그 뒤 오늘 안에 비 오는 첫 시각 (단기예보)
today_known: bool = False # 오늘 남은 시간 예보가 있어 '오늘 비 안 와요'라고 말할 수 있는지
air: Optional[AirGrade] = None
uv: Optional[float] = None
temp_min: Optional[float] = None
@@ -57,6 +59,8 @@ def hero_stats(x: HeroInput) -> list[HeroStatItem]:
alerts: list[HeroStatItem] = []
if x.rain_at is not None:
alerts.append(HeroStatItem("rain", "umbrella", "지금 비", _rain_value(x.now, x.rain_at), "rain"))
elif x.rain_later_at is not None:
alerts.append(HeroStatItem("rain", "umbrella", "오늘 비", _rain_value(x.now, x.rain_later_at), "rain"))
if x.air in (AirGrade.BAD, AirGrade.VERY_BAD):
alerts.append(HeroStatItem("air", "mask", "미세먼지", GRADE_LABEL[x.air], "warn"))
if not x.night and x.uv is not None and x.uv >= UV_HIGH:
@@ -68,12 +72,10 @@ 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.air is not None:
fills.append(HeroStatItem("air", "vent", "미세먼지", GRADE_LABEL[x.air]))
if not x.night and x.uv is not None:
fills.append(HeroStatItem("uv", "glasses", "자외선", f"{round(x.uv)} · {uv_label(x.uv)}"))
if x.today_known and x.rain_at is None and x.rain_later_at is None:
fills.append(HeroStatItem("rain", "moon" if x.night else "sun", "오늘 밤 비" if x.night else "오늘 비", "안 와요"))
if x.night and x.moon:
fills.append(HeroStatItem("moon", "moon", "오늘 밤 달", x.moon))