From b6664f2b5df7659cef33a54f32a0823acfd7c13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EA=B2=BD?= Date: Tue, 24 Nov 2026 11:28:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=82=A0=EC=94=A8=EC=97=90=20=EA=BC=AD?= =?UTF-8?q?=20=EB=A7=9E=EB=8A=94=20=EA=B0=81=EC=9D=B4=201=EC=9C=84?= =?UTF-8?q?=EC=97=AC=EB=8F=84=20=EB=A7=90=ED=92=8D=EC=84=A0=EC=9D=B4=20?= =?UTF-8?q?=EB=8A=98=20'=EC=89=AC=EC=96=B4=20=EA=B0=80=EC=9A=94'=EC=9D=B4?= =?UTF-8?q?=EB=8D=98=20=EA=B2=83=20=E2=80=94=20=EA=B6=8C=ED=95=98=EB=8A=94?= =?UTF-8?q?=20=EA=B8=B0=EC=A4=80=EC=9D=84=2070=EC=A0=90=EC=97=90=EC=84=9C?= =?UTF-8?q?=2065=EC=A0=90=EC=9C=BC=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 화면 점수는 계산 점수에 중요도 배율(상 1.0, 중 0.85, 하 0.7)을 곱한 값이라 '하' 각은 만점이어도 70점. 겨울에 군밤각(계산 97점 → 화면 68점)이 1위여도 '지금은 쉬어 가요'가 나왔다 - 서버(feed_service.py)는 판정을 hero_bubble 함수로 꺼내고 테스트 추가, 웹(TodayPage.tsx)은 두 군데 있던 70을 BUBBLE_MIN_SCORE 하나로 묶음 - 앱 소스(mobile/)는 웹뷰 셸이 쓰지 않는 코드라 그대로 둠 --- backend/services/feed_service.py | 10 +++++++++- backend/tests/test_feed.py | 9 +++++++++ frontend/src/b/TodayPage.tsx | 7 +++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/backend/services/feed_service.py b/backend/services/feed_service.py index 37a3cb9..2f7c570 100644 --- a/backend/services/feed_service.py +++ b/backend/services/feed_service.py @@ -284,6 +284,14 @@ def _hero_tomorrow(day: date, board: IndexBoard) -> HeroTomorrow: ) +HERO_BUBBLE_MIN_SCORE = 65 # 화면의 TodayPage.tsx BUBBLE_MIN_SCORE 와 같은 값 + + +def hero_bubble(name: str, score: int) -> str: + """히어로 말풍선: 1위 각의 화면 점수(중요도 배율을 곱한 점수)가 기준 이상이면 그 각을 권하고, 아니면 쉬어 가자고 한다.""" + return f"지금은 {name}!" if score >= HERO_BUBBLE_MIN_SCORE else "지금은 쉬어 가요" + + def _top(i: IndexItem) -> TopIndex: d = i.definition return TopIndex(index_id=d.index_id, code=d.code, name=d.name, icon=d.icon, score=i.score.score, rank=i.rank, summary=i.score.summary, active=i.active, @@ -496,7 +504,7 @@ class FeedService: top = board.ranked[0] if board and board.ranked else None bubble = None if top is not None: - bubble = f"지금은 {top.definition.name}!" if top.score.score >= 70 else "지금은 쉬어 가요" + bubble = hero_bubble(top.definition.name, top.score.score) x_in = _hero_input(now, slot, cur, now_w, today, uv, f"{moon[0].name}, {moon[1]}" if moon else None) return Hero( now_at=now, sky_mode=_SKY_MODE[slot], diff --git a/backend/tests/test_feed.py b/backend/tests/test_feed.py index 4a5f5b2..cc9ef0b 100644 --- a/backend/tests/test_feed.py +++ b/backend/tests/test_feed.py @@ -132,6 +132,15 @@ async def test_hero_shows_the_observed_current_weather(offline, monkeypatch): assert (hero["temp_c"], hero["humidity"]) == (3.3, 88) +def test_hero_bubble_recommends_the_top_gak_from_65_points(): + """중요도 '하' 각은 만점이어도 화면 점수가 70점이라, 기준이 70이면 날씨에 꼭 맞아도(예: 겨울 군밤각 68점) 늘 '쉬어 가요'였다.""" + from services.feed_service import hero_bubble + + assert hero_bubble("군밤각", 68) == "지금은 군밤각!" + assert hero_bubble("군밤각", 65) == "지금은 군밤각!" + assert hero_bubble("군밤각", 64) == "지금은 쉬어 가요" + + def _card(post_type, post_id=1): from datetime import datetime diff --git a/frontend/src/b/TodayPage.tsx b/frontend/src/b/TodayPage.tsx index 3cad895..e9f2135 100644 --- a/frontend/src/b/TodayPage.tsx +++ b/frontend/src/b/TodayPage.tsx @@ -42,6 +42,9 @@ import { track } from '../lib/analytics' type Mode = 'now' | TimeKind +/** 1위 각이 이 점수(중요도 배율을 곱한 화면 점수) 이상이면 말풍선이 그 각을 권한다. 서버 feed_service.py HERO_BUBBLE_MIN_SCORE 와 같은 값 */ +const BUBBLE_MIN_SCORE = 65 + // 하루 흐름 칸 순서와 칸마다 볼 예보 시각 const KINDS: TimeKind[] = ['morning', 'day', 'sunset', 'night'] const PREVIEW: Record = { @@ -255,12 +258,12 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps const tmrWhen = mode === 'now' ? '내일' : `내일 ${PREVIEW[mode].label}` const bubble = tmr ? top1 - ? top1.score >= 70 + ? top1.score >= BUBBLE_MIN_SCORE ? `${tmrWhen}은 ${top1.name}!` : `${tmrWhen}은 쉬어 가요` : null : slotTop - ? slotTop.score >= 70 + ? slotTop.score >= BUBBLE_MIN_SCORE ? `${when}은 ${slotTop.name}!` : `${when}은 쉬어 가요` : hero