feat: 날씨 점수 근거 버튼을 구름에 가리던 해 구석 '?'에서 상태 줄 끝 '점수 근거 ›'로(해를 눌러도 열림), 근거 창에 지금 상태(습도·불쾌지수·자외선·미세먼지) 실제 값과 기준 추가
This commit is contained in:
1 parent
1888dd6cf3
commit
eb84a72c2f
6 files changed
+80
-30
No files matched your search
@@ -148,6 +148,7 @@ def _hero_input(
|
||||
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,
|
||||
pm25=now_w.air.pm25 if now_w and now_w.air else None, pm10=now_w.air.pm10 if now_w and now_w.air else None,
|
||||
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,
|
||||
moon=moon, humidity=cur.humidity if cur else None, discomfort=cur.discomfort_index if cur else None,
|
||||
@@ -475,7 +476,7 @@ class FeedService:
|
||||
top1=_top(top) if top else None, bubble=bubble,
|
||||
moon_name=moon[0].name if moon else None, moon_pct=round(moon[0].lit * 100) if moon else None,
|
||||
stats=[HeroStat(icon=x.icon, label=x.label, value=x.value, tone=x.tone) for x in hero_stats(x_in)],
|
||||
status=[HeroStat(icon=x.icon, label=x.label, value=x.value, tone=x.tone) for x in hero_status(x_in)],
|
||||
status=[HeroStat(icon=x.icon, label=x.label, value=x.value, tone=x.tone, detail=x.detail) for x in hero_status(x_in)],
|
||||
tomorrow=_hero_tomorrow(now.date() + timedelta(days=1), board) if board else None,
|
||||
)
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class HeroStatItem:
|
||||
label: str
|
||||
value: str
|
||||
tone: Tone = "normal"
|
||||
detail: Optional[str] = None # 단계 이름 밑의 실제 값 (예: 68%, 72, 2, 초미세먼지 15㎍/㎥)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -34,6 +35,8 @@ class HeroInput:
|
||||
rain_later_at: Optional[datetime] = None # 그 뒤 오늘 안에 비 오는 첫 시각 (단기예보)
|
||||
today_known: bool = False # 오늘 남은 시간 예보가 있어 '오늘 비 안 와요'라고 말할 수 있는지
|
||||
air: Optional[AirGrade] = None
|
||||
pm25: Optional[int] = None
|
||||
pm10: Optional[int] = None
|
||||
uv: Optional[float] = None
|
||||
temp_min: Optional[float] = None
|
||||
temp_max: Optional[float] = None
|
||||
@@ -69,13 +72,14 @@ def hero_status(x: HeroInput) -> list[HeroStatItem]:
|
||||
"""히어로 상태 한 줄: 습도·불쾌지수(늘)·자외선(해 있을 때, 저녁 포함)·미세먼지를 단계 이름으로. 값이 없는 칸은 뺀다. 조심할 것만 warn."""
|
||||
out: list[HeroStatItem] = []
|
||||
if x.humidity is not None:
|
||||
out.append(HeroStatItem("humidity", "muggy", "습도", humidity_label(x.humidity)))
|
||||
out.append(HeroStatItem("humidity", "muggy", "습도", humidity_label(x.humidity), detail=f"{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"))
|
||||
out.append(HeroStatItem("discomfort", "muggy", "불쾌지수", discomfort_label(x.discomfort), "warn" if x.discomfort >= MUGGY_DI else "normal", detail=str(x.discomfort)))
|
||||
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"))
|
||||
out.append(HeroStatItem("uv", "glasses", "자외선", uv_label(x.uv), "warn" if x.uv >= UV_HIGH else "normal", detail=f"{x.uv:g}"))
|
||||
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"))
|
||||
pm = " · ".join(s for s in (f"초미세먼지 {x.pm25}㎍/㎥" if x.pm25 is not None else "", f"미세먼지 {x.pm10}㎍/㎥" if x.pm10 is not None else "") if s) or None
|
||||
out.append(HeroStatItem("air", "mask", "미세먼지", GRADE_LABEL[x.air], "warn" if x.air in (AirGrade.BAD, AirGrade.VERY_BAD) else "normal", detail=pm))
|
||||
return out
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user