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