fix: 날씨에 꼭 맞는 각이 1위여도 말풍선이 늘 '쉬어 가요'이던 것 — 권하는 기준을 70점에서 65점으로
- 화면 점수는 계산 점수에 중요도 배율(상 1.0, 중 0.85, 하 0.7)을 곱한 값이라 '하' 각은 만점이어도 70점. 겨울에 군밤각(계산 97점 → 화면 68점)이 1위여도 '지금은 쉬어 가요'가 나왔다 - 서버(feed_service.py)는 판정을 hero_bubble 함수로 꺼내고 테스트 추가, 웹(TodayPage.tsx)은 두 군데 있던 70을 BUBBLE_MIN_SCORE 하나로 묶음 - 앱 소스(mobile/)는 웹뷰 셸이 쓰지 않는 코드라 그대로 둠
This commit is contained in:
1 parent
6c29d71573
commit
b6664f2b5d
3 files changed
+23
-3
No files matched your search
@@ -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],
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user