feat: 날씨 위젯에서 아침·낮·저녁·밤을 눌러 그 시간대 점수와 한마디 보기
- 서버가 카드 데이터에 시간대별 날씨 점수와 한마디(앱과 같은 65점 규칙: '오늘 낮은 ○○각!'/'…쉬어 가요')를 넣음 - 카드 4칸을 버튼으로: 누르면 점수·하늘·해와 달·한마디가 그 시간대로 바뀌고, 상세형 요약·상태 줄은 숨김(자리는 유지) - 같은 칸을 다시 누르면 다시 그리지 않음, 누른 칸에 초점 유지, 휴대폰 터치 반짝임 없앰 - ASSET_VERSION 11
This commit is contained in:
1 parent
dc8201e5f5
commit
c5129d14ed
6 files changed
+259
-40
No files matched your search
@@ -22,11 +22,12 @@ from config.settings import settings
|
||||
from crud.region_crud import RegionCRUD
|
||||
from crud.widget_crud import WidgetCRUD
|
||||
from router.v1.feed.protocol import Res_Feed
|
||||
from services.calc.day_slot import SLOT_LABEL
|
||||
from services.embed_referer import OTHER_HOST, UNKNOWN_HOST, view_host
|
||||
from services.feed_service import FeedService
|
||||
from services.feed_service import _SKY_MODE, HERO_BUBBLE_MIN_SCORE, FeedService
|
||||
from services.weather_service import Slot, TodayWeather, WeatherService
|
||||
|
||||
ASSET_VERSION = "8" # 카드 파일(card.css·card.js)을 고치면 올린다
|
||||
ASSET_VERSION = "11" # 카드 파일(card.css·card.js)을 고치면 올린다
|
||||
KINDS = ("side", "home")
|
||||
BGS = ("sky", "light", "dark")
|
||||
DAILY_HOST_CAP = 500 # 하루에 따로 셀 호스트 수. 넘친 새 호스트는 OTHER_HOST 로 센다
|
||||
@@ -81,6 +82,23 @@ def _slot(s: Slot) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def _picks(feed: Res_Feed, sky_mode: str) -> dict:
|
||||
"""카드 칸(morning·day·sunset·night)마다 그 시간대 한마디. 앱 TodayPage.tsx 의 atSlot·bubble 과 같은 규칙:
|
||||
그 구간 점수·순위가 다 있는 각 중 순위가 가장 앞선 것(같으면 피드 순서)의 구간 점수가 기준 이상이면 그 각을 권한다.
|
||||
머리말은 지금 칸(hero.sky_mode)이면 '지금', 아니면 '오늘 아침' 등. 고를 각이 없는 칸은 뺀다.
|
||||
각 설명(summary)은 넣지 않는다: 지금 시각 기준 글이라 카드는 다른 칸을 고르면 요약을 감춘다."""
|
||||
out = {}
|
||||
for slot, cell in _SKY_MODE.items():
|
||||
on = [g for g in feed.stories if slot in g.slot_ranks and slot in g.slots]
|
||||
if not on:
|
||||
continue
|
||||
top = min(on, key=lambda g: g.slot_ranks[slot]) # min 은 같은 값이면 앞의 것을 고른다
|
||||
when = "지금" if cell == sky_mode else f"오늘 {SLOT_LABEL[slot]}"
|
||||
bubble = f"{when}은 {top.name}!" if top.slots[slot] >= HERO_BUBBLE_MIN_SCORE else f"{when}은 쉬어 가요"
|
||||
out[cell] = {"bubble": bubble}
|
||||
return out
|
||||
|
||||
|
||||
def card_data(feed: Res_Feed, today: TodayWeather, name: str, now: datetime) -> Optional[dict]:
|
||||
"""카드가 그릴 값 (링크는 부른 사이트마다 달라 빼고 저장한다). 오늘 값이 아니거나 그릴 것이 없으면 None."""
|
||||
h = feed.hero
|
||||
@@ -96,10 +114,13 @@ def card_data(feed: Res_Feed, today: TodayWeather, name: str, now: datetime) ->
|
||||
"name": name,
|
||||
"hero": {
|
||||
"now_at": h.now_at.astimezone(KST).isoformat(), "sky_mode": h.sky_mode, "temp_c": h.temp_c, "weather_score": h.weather_score,
|
||||
# 서버 구간 이름 → 카드 칸 이름 (evening → sunset)
|
||||
"weather_slots": {_SKY_MODE[k]: v for k, v in h.weather_slots.items() if k in _SKY_MODE},
|
||||
"bubble": h.bubble, "top1": {"summary": h.top1.summary} if h.top1 else None,
|
||||
"status": [{"label": s.label, "value": s.value, "tone": s.tone} for s in h.status],
|
||||
"moon_name": h.moon_name, "moon_pct": h.moon_pct,
|
||||
},
|
||||
"picks": _picks(feed, h.sky_mode),
|
||||
"today": {"day": today.day.isoformat(), "slots": slots},
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user