feat: 각 포스트 본문 맨 앞에 그 점수 구간 설명 문장

This commit is contained in:
minaChoi committed 2026-10-07 16:37:50 +09:00
1 parent f9cac00bc0
commit 622f569f68
2 files changed
+24 -4

No files matched your search

+13 -4
View File
@@ -648,15 +648,24 @@ class FeedService:
slides=[RowsSlide(kind="rows", eyebrow="오늘의 한 문장", line=a.body[0], icon=a.icon, rows=rows)], share_messages=[a.body[0]])
def _band_sentence(sentences: Optional[dict], score: int) -> Optional[str]:
"""seed 의 점수 구간 설명 {"0": …, "30": …, "60": …, "80": …} 중 점수가 들어가는 구간 문장."""
lo = next((x for x in sorted((int(k) for k in sentences or {}), reverse=True) if score >= x), None)
return sentences[str(lo)] if lo is not None else None
def _gak_caption(i: IndexItem) -> str:
"""슬라이드에 없는 내일 점수, 없으면 하기 좋은 시간."""
"""점수 구간 설명 문장 + 슬라이드에 없는 내일 점수(없으면 하기 좋은 시간)."""
band = _band_sentence(i.definition.sentences, i.score.score)
nxt = next((x for x in i.trend if x.score_date > i.score.score_date), None)
if nxt is not None:
diff = nxt.score - i.score.score
how = "비슷해요" if abs(diff) < 5 else f"오늘보다 {abs(diff)}점 {'높아요' if diff > 0 else '낮아요'}"
return f"내일은 {nxt.score}점, {how}."
spans = [_span(w) for w in i.definition.windows or []]
return f"하기 좋은 때는 {spans[0][0]}~{spans[0][1]}시예요." if spans else f"오늘의 각 {i.rank}위예요."
tail = f"내일은 {nxt.score}점, {how}."
else:
spans = [_span(w) for w in i.definition.windows or []]
tail = f"하기 좋은 때는 {spans[0][0]}~{spans[0][1]}시예요." if spans else f"오늘의 각 {i.rank}위예요."
return f"{band} {tail}" if band else tail
def _temp_change(today: Optional[TodayWeather], tomorrow: Optional[TodayWeather]) -> Optional[str]: