From 3a73a44cb0e5df1063eab4ea59d79b7076742d24 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Thu, 8 Oct 2026 17:20:06 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=9E=88=EC=96=B4=EB=A1=9C=20=EC=B9=B8?= =?UTF-8?q?=EC=9D=84=20=EC=A7=80=EA=B8=88=C2=B7=EC=8A=B5=EB=8F=84=C2=B7?= =?UTF-8?q?=EB=B6=88=EC=BE=8C=EC=A7=80=EC=88=98=C2=B7=EC=83=81=ED=99=A9=20?= =?UTF-8?q?1=EC=B9=B8=EC=9C=BC=EB=A1=9C=20=E2=80=94=20=EC=8A=B5=EB=8F=84?= =?UTF-8?q?=C2=B7=EB=B6=88=EC=BE=8C=EC=A7=80=EC=88=98=20=EB=8A=98=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 2 +- backend/router/v1/feed/protocol.py | 5 +++-- backend/services/feed_service.py | 3 ++- backend/services/hero_stats.py | 12 ++---------- backend/tests/test_hero_stats.py | 13 +++++++------ frontend/src/api/client/types.gen.ts | 10 +++++++++- frontend/src/b/TodayPage.tsx | 9 +++++++-- 7 files changed, 31 insertions(+), 23 deletions(-) diff --git a/TODO.md b/TODO.md index 2a54985..b880681 100644 --- a/TODO.md +++ b/TODO.md @@ -143,7 +143,7 @@ | [ ] | 광주·전남 구는 행사가 안 잡힐 수 있음 — 구 코드 시도는 `12`인데 행사 수집·`event.sido_code`는 `29`(광주)·`46`(전남). 좌표 없는 행사는 `is_nearby`·`nearby_sidos`에서 빠짐 | 포스트 시도 나누기 중 발견 (10/8) | `backend/services/week_service.py:125,144`, `backend/services/external/culture_api.py:28` | | [x] | 전체 날씨 점수 기준 강화 — 100점은 '1년에 하루' 수준으로만 → 각과 같은 계산에 기준만 좁힘(체감 21±0.5°·습도 45~55%·해 90%↑·바람 1m/s↓·초미세먼지 10↓, 사용자 결정 '기준만 좁히기'). 실제 연 몇 번 나오는지는 미확인 (`docs/점수_계산식.md` 3) | 10/8 회의 결정 | `backend/services/index_service.py:203` | | [x] | 각 점수를 아침·낮·저녁·밤 시간대별로 → 지금 구간 점수로 순위, 안 겹치는 각은 순위·피드에서 빼고 스토리·전체엔 '지금 아님'. 히어로는 '지금 날씨 점수'(지금 구간). 운영 DB에 `index_score.slots` 칸 추가 필요(배포 때 `init.sql`의 ALTER) | 10/8 회의 결정 | `backend/services/calc/index_calc.py:297` | -| [ ] | 히어로에 습도·불쾌지수 항상 표시 — 지금은 상황별 두 칸이라 불쾌지수는 일정 수치 이상일 때만 | 10/8 회의 결정 | `frontend/src/b/TodayPage.tsx` (`HeroStat`) | +| [x] | 히어로에 습도·불쾌지수 항상 표시 → 4칸(지금·습도·불쾌지수·상황 1칸, 사용자 결정). 불쾌지수 75 이상이면 경고 색, 상황 칸 후보에서 불쾌지수 뺌 | 10/8 회의 결정 | `frontend/src/b/TodayPage.tsx` (`HeroStat`) | | [ ] | 달 '밝기 %' 정의(밝기인지 보이는 면적인지) + 구름·달 모양 반영 산정 로직 | 10/8 회의 | `backend/services/calc/moon.py` | | [x] | 노을: 점수 강조(히어로에 점수 크게) + 골든아워·블루아워 설명. 결론은 다음에 오는 것(해 뜨기 전·밤엔 일출, 그 사이엔 노을)으로, 피드 노을 카드도 같이 (사용자 결정 '각·노을도 지금 기준') | 10/8 회의, 사용자 결정 | `frontend/src/b/SkyPage.tsx`, `backend/services/sky_service.py` | | [ ] | 주말 예보 UI 개선 — 회의에서 구체 내용 없음 | 10/8 회의 | `frontend/src/b/WeekPage.tsx` | diff --git a/backend/router/v1/feed/protocol.py b/backend/router/v1/feed/protocol.py index b495804..f5d3d74 100644 --- a/backend/router/v1/feed/protocol.py +++ b/backend/router/v1/feed/protocol.py @@ -146,7 +146,8 @@ class Hero(WebPacketProtocol): sky_mode: Literal["morning", "day", "sunset", "night"] temp_c: Optional[float] = None feels_c: Optional[float] = None - discomfort: Optional[int] = None + humidity: Optional[int] = Field(default=None, description="지금 습도 %. 히어로에 늘 보인다") + discomfort: Optional[int] = Field(default=None, description="지금 불쾌지수. 히어로에 늘 보인다") discomfort_label: Optional[str] = None rain_2h_text: Optional[str] = None will_rain_2h: Optional[bool] = None @@ -155,7 +156,7 @@ class Hero(WebPacketProtocol): bubble: Optional[str] = None moon_name: Optional[str] = Field(default=None, description="오늘 밤 달 모양: 삭·초승달·상현달·차오르는 달·보름달·기우는 달·하현달·그믐달") moon_pct: Optional[int] = Field(default=None, description="달이 밝게 보이는 비율 0~100") - stats: list[HeroStat] = Field(default_factory=list, description="히어로 두 칸. 지금 챙길 것(비·미세먼지·자외선·일교차·체감·불쾌지수) 먼저") + stats: list[HeroStat] = Field(default_factory=list, description="히어로 상황 칸 1개. 지금 챙길 것(비·미세먼지·자외선·일교차·체감) 먼저") class BandEvent(WebPacketProtocol): diff --git a/backend/services/feed_service.py b/backend/services/feed_service.py index 90e5ed9..a84a49e 100644 --- a/backend/services/feed_service.py +++ b/backend/services/feed_service.py @@ -144,7 +144,7 @@ def _hero_input(now: datetime, slot: str, cur: Optional[WeatherHourly], now_w: O 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), - 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, + temp=float(cur.temp_c) if cur else None, feels=float(cur.feels_c) if cur else None, moon=phase_name(_tonight(now)), ) @@ -430,6 +430,7 @@ class FeedService: return Hero( now_at=now, sky_mode=_SKY_MODE[slot], temp_c=float(cur.temp_c) if cur else None, feels_c=float(cur.feels_c) if cur else None, + humidity=cur.humidity if cur else None, discomfort=cur.discomfort_index if cur else None, discomfort_label=_discomfort_label(cur.discomfort_index) if cur else None, rain_2h_text=now_w.rain_2h_text if now_w else None, will_rain_2h=now_w.will_rain_2h if now_w else None, weather_score=board.weather_score if board else None, top1=_top(top) if top else None, bubble=bubble, diff --git a/backend/services/hero_stats.py b/backend/services/hero_stats.py index 02b501c..031f777 100644 --- a/backend/services/hero_stats.py +++ b/backend/services/hero_stats.py @@ -12,8 +12,7 @@ Tone = Literal["normal", "warn", "rain"] UV_HIGH = 6.0 TEMP_SWING_C = 10.0 WIND_CHILL_C = 3.0 -MUGGY = 75 -SHOWN = 2 +SHOWN = 1 @dataclass(frozen=True) @@ -38,7 +37,6 @@ class HeroInput: temp_max: Optional[float] = None temp: Optional[float] = None feels: Optional[float] = None - discomfort: Optional[int] = None moon: Optional[str] = None @@ -46,16 +44,12 @@ def uv_label(uv: float) -> str: return "낮음" if uv < 3 else "보통" if uv < 6 else "높음" if uv < 8 else "매우 높음" if uv < 11 else "위험" -def _discomfort_label(v: int) -> str: - return "보통" if v < 75 else "높음" if v < 80 else "매우 높음" - - def _rain_value(now: datetime, at: datetime) -> str: return "지금 와요" if at <= now else f"{hour_label(at.astimezone(KST).hour)}쯤 와요" 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")) @@ -69,8 +63,6 @@ def hero_stats(x: HeroInput) -> list[HeroStatItem]: alerts.append(HeroStatItem("swing", "coldwind", f"일교차 {round(x.temp_max - x.temp_min)}°", "아침엔 겉옷")) if x.temp is not None and x.feels is not None and x.temp - x.feels >= WIND_CHILL_C: alerts.append(HeroStatItem("chill", "coldwind", f"체감 {round(x.feels)}°", "바람 쌀쌀")) - 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] = [] diff --git a/backend/tests/test_hero_stats.py b/backend/tests/test_hero_stats.py index d7b0cc0..fb0ef59 100644 --- a/backend/tests/test_hero_stats.py +++ b/backend/tests/test_hero_stats.py @@ -12,8 +12,9 @@ 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, 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")] + x = HeroInput(now=NOW, night=False, air=AirGrade.GOOD, uv=6.1, temp_min=13, temp_max=23, temp=23, feels=23) + assert _view(x) == [("glasses", "자외선", "6 · 높음", "warn")] + assert _view(HeroInput(now=NOW, night=False, air=AirGrade.GOOD, uv=2.0, temp_min=13, temp_max=23)) == [("coldwind", "일교차 10°", "아침엔 겉옷", "normal")] def test_rain_comes_first(): @@ -30,12 +31,12 @@ def test_rain_later_today_and_no_rain_today(): def test_bad_air_beats_uv_and_wears_mask(): x = HeroInput(now=NOW, night=False, air=AirGrade.VERY_BAD, uv=7.2) - assert _view(x) == [("mask", "미세먼지", "매우나쁨", "warn"), ("glasses", "자외선", "7 · 높음", "warn")] + assert _view(x) == [("mask", "미세먼지", "매우나쁨", "warn")] -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_night_without_alert_shows_moon_and_no_card_for_no_rain(): + x = HeroInput(now=NOW.replace(hour=21), night=True, uv=0.0, temp=28, feels=31, moon="보름달") + assert _view(x) == [("moon", "오늘 밤 달", "보름달", "normal")] def test_one_coldwind_card_only(): diff --git a/frontend/src/api/client/types.gen.ts b/frontend/src/api/client/types.gen.ts index 90127a9..6971d57 100644 --- a/frontend/src/api/client/types.gen.ts +++ b/frontend/src/api/client/types.gen.ts @@ -561,8 +561,16 @@ export type Hero = { * Feels C */ feels_c?: number | null; + /** + * Humidity + * + * 지금 습도 %. 히어로에 늘 보인다 + */ + humidity?: number | null; /** * Discomfort + * + * 지금 불쾌지수. 히어로에 늘 보인다 */ discomfort?: number | null; /** @@ -601,7 +609,7 @@ export type Hero = { /** * Stats * - * 히어로 두 칸. 지금 챙길 것(비·미세먼지·자외선·일교차·체감·불쾌지수) 먼저 + * 히어로 상황 칸 1개. 지금 챙길 것(비·미세먼지·자외선·일교차·체감) 먼저 */ stats?: Array; }; diff --git a/frontend/src/b/TodayPage.tsx b/frontend/src/b/TodayPage.tsx index 584fca8..18ff165 100644 --- a/frontend/src/b/TodayPage.tsx +++ b/frontend/src/b/TodayPage.tsx @@ -31,7 +31,8 @@ const PREVIEW: Record } // 히어로 칸을 받아 오는 동안 자리만 잡아 둔다 -const STAT_HOLD = ['a', 'b'] +const STAT_HOLD = ['a'] +const MUGGY = 75 // 불쾌지수 이 이상이면 경고 색 const STARS = Array.from({ length: 26 }, (_, i) => ({ left: `${(i * 37) % 100}%`, top: `${(i * 53) % 60}%`, opacity: 0.4 + ((i * 7) % 6) / 10 })) // 별똥별 셋: 위치·길이·주기를 엇갈려 하나씩 떨어지게 @@ -131,9 +132,13 @@ function Hero({ hero, today, feedLoad, todayLoad }: HeroProps) {