feat: 노을 문구 확정안 반영 — 큰 글씨 '오늘 노을은 18:10에 가장 붉을 거예요', 안 보이는 날은 이유, 내일 안내는 그날 하늘·시각, 자세히는 점수 뜻과 어림값 안내만

This commit is contained in:
minaChoi committed 2026-10-12 10:41:03 +09:00
1 parent f5575711fe
commit b346838054
10 files changed
+103 -65

No files matched your search

+14 -18
View File
@@ -28,7 +28,7 @@ from services.air_service import pm10_grade, pm25_grade
from services.calc.day_slot import NIGHT_AFTER_SUNSET, slot_of
from services.calc.index_calc import rank_score
from services.calc.moon import MoonNight, nearest, night, view_line
from services.calc.sky_score import GRADE_LABEL
from services.calc.sky_score import GRADE_LABEL, sky_title
from services.calc.sun import sun_times
from services.hero_stats import UV_HIGH, HeroInput, hero_stats, uv_label
from services.index_service import IndexBoard, IndexItem, IndexService
@@ -627,14 +627,13 @@ class FeedService:
return None
label = uv_label(top)
at = peak.forecast_at.astimezone(KST)
rows = [Row(label=f"{r.forecast_at.astimezone(KST).hour}시", value=f"{round(float(r.uv_index))} · {uv_label(float(r.uv_index))}") for r in c.uv]
high = top >= UV_HIGH
if high:
rows.append(Row(label="이렇게 해요", value="선크림 바르고, 모자·선글라스 챙겨요"))
line = f"{hour_label(at.hour)} 무렵 자외선 {label},\n" + ("선크림 꼭 챙겨요" if high else "오래 밖에 있으면 선크림")
return PostData(**base, title=f"자외선 {label}", icon="glasses", caption=f"가장 셀 때 {hour_label(at.hour)} · {round(top)}",
rows = [Row(label=f"{r.forecast_at.astimezone(KST).hour}시", value=uv_label(float(r.uv_index))) for r in c.uv]
when = "점심때" if at.hour == 12 else f"{hour_label(at.hour)} 무렵"
todo = "선크림·모자·선글라스 챙기고 그늘로 다녀요" if top >= UV_HIGH else "선크림·모자 챙겨요"
line = f"오늘 자외선 지수 {label}\n{when} 나가면 {todo}"
return PostData(**base, title=f"자외선 지수 {label}", icon="glasses", caption=f"가장 셀 때 {hour_label(at.hour)}",
slides=[RowsSlide(kind="rows", eyebrow=f"오늘 자외선 · {c.region.short_name}", line=line, icon="glasses", rows=rows)],
share_messages=[f"오늘 자외선 {label}, 선크림 챙겨!"])
share_messages=[f"오늘 자외선 지수 {label}, 선크림 챙겨!"])
def _air(self, base: dict, c: "_Ctx") -> Optional[PostData]:
"""가까운 측정소의 지금 초미세먼지·미세먼지. 측정값이 없거나 3시간 넘게 지났으면 끈다."""
@@ -656,31 +655,28 @@ class FeedService:
share_messages=[f"{c.region.short_name} 지금 미세먼지 {label} {tail}"])
def _sunset(self, base: dict, c: "_Ctx") -> Optional[PostData]:
"""노을 탭 결론과 같은 것: 해 뜨기 전·밤엔 일출, 그 사이엔 노을. 하늘 상황으로 말하고, '쉬어요'면 한 줄 카드."""
"""노을 탭 결론과 같은 것: 해 뜨기 전·밤엔 일출, 그 사이엔 노을. 노을 탭 히어로와 같은 문장, 안 볼 만한 날은 한 줄 카드."""
plan = c.sky.plan
if plan is None:
return None
target, when, rise = plan.target, plan.when, plan.kind is SkyType.SUNRISE
word, icon = ("일출", "sun") if rise else ("노을", "sunset")
sit = SkySituation(target.situation) if target.situation else None
# 노을 탭 히어로와 같은 쉬운 말 한 줄 (공기가 뿌예 결론이 낮아졌으면 그 이유까지)
line = plan.situation_label or GRADE_LABEL[SkyGrade(target.grade)]
line = plan.situation_label or "" # 보이는 날만 그날 하늘 한 줄
better = plan.outlook
sun = next((b for b in target.best_times if b["kind"] == "sun"), target.best_times[0])
sun_at = datetime.fromisoformat(sun["at"]).astimezone(KST)
if day_verdict(target) == "rest":
return PostData(**base, size="line", title=f"{when} {word}은 쉬어요", icon=icon, caption=f"{line}." + (f" {better}" if better else ""),
slides=[], share_messages=[f"{when} {word}은 쉬어요, {line}"])
return PostData(**base, size="line", title=plan.title, icon=icon, caption=" ".join(filter(None, [line and f"{line}.", better])),
slides=[], share_messages=[plan.title])
cuts = [Cut(**b) for b in target.best_times if b["kind"] != "peak"]
slides = [SunsetSlide(kind="sunset", eyebrow=f"{when} {word} · {c.region.name}", line=line, score=target.score,
grade_label=GRADE_LABEL[SkyGrade(target.grade)], cuts=cuts, situation=sit,
headline=plan.headline, peak_at=plan.best_at)]
headline=sky_title(sit, plan.kind, None, plan.best_at) or plan.title, peak_at=plan.best_at)]
if c.sky.spots and not rise:
slides.append(RowsSlide(kind="rows", eyebrow="가까운 노을 명소", line=f"해 지는 {compass(c.sky.sunset_azimuth)}쪽", icon="sunset",
rows=[Row(label=f"{n + 1} {x.spot.name}", value=f"{compass(x.direction)} {x.distance_km}km", place=x.spot.name) for n, x in enumerate(c.sky.spots)]))
caption = better or ("보통 해 뜨기 10~20분 전이 가장 붉어요." if rise else "보통 해 진 뒤 10~20분이 가장 붉어요.")
share = f"{when} 일출, {line} 🌅 {sun_at:%H:%M}에 해 떠요" if rise else f"{when} 노을, {line} 🌇 {sun_at:%H:%M}에 해 져요"
return PostData(**base, title=f"{when} {word} · {line}", icon=icon, caption=caption, slides=slides, share_messages=[share])
share = f"{plan.title} {'🌅' if rise else '🌇'}"
return PostData(**base, title=plan.title, icon=icon, caption=caption, slides=slides, share_messages=[share])
def _tomorrow(self, base: dict, c: "_Ctx") -> PostData:
tomorrow = c.now.date() + timedelta(days=1)