fix: 히어로 상태 한 줄 자외선을 저녁 구간(일몰 2시간 전~)에도 보이게, 밤 구간에만 뺀다
This commit is contained in:
1 parent
0b8eb84b55
commit
72301e9f10
4 files changed
+8
-5
No files matched your search
@@ -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),
|
||||
|
||||
@@ -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"))
|
||||
|
||||
Reference in new issue
Block a user