feat: 10/6 회의 반영 — 각 점수 하향, 주말 카드 매일·다음 주말, 일반구를 시로 합침
- 각 점수: 편한 범위 안에서도 최적값에서만 100, 가장 나쁜 요인이 전체를 끌어내림 - 피드 노을 시간대 각 정렬 오류 수정 - 주말 카드 매일 노출, 예보가 닿으면 다음 주말 슬라이드 추가, 주말·행사 탭 열흘 - 지역 256→230 (일반구 39개를 시 13개로) - 회의 기록과 TODO.md 추가
This commit is contained in:
1 parent
a9ddbaab3c
commit
14ddebd040
12 files changed
+156
-76
No files matched your search
@@ -56,6 +56,7 @@ ORDER = {
|
||||
_SKY_MODE = {"morning": "morning", "day": "day", "evening": "sunset", "night": "night"}
|
||||
_CATEGORY_META = {ArticleCategory.SEASON.value: "계절 소식", ArticleCategory.TIP.value: "날씨 상식", ArticleCategory.GAK.value: "각 원리", ArticleCategory.QUOTE.value: "한 문장"}
|
||||
_FEED_TTL_MAX = 3600
|
||||
_SUNSET_HOUR = 18 # 노을 시간대 각의 대략적인 순서용
|
||||
_RAIN_PROB = 40
|
||||
_SUNSET_FULL = 60
|
||||
_FEED_DAY_START = 3 # 03:00 에 그날 카드가 바뀐다
|
||||
@@ -100,10 +101,26 @@ def feed_ttl_sec(now: datetime, sunset_at: datetime) -> int:
|
||||
|
||||
def _gak_key(item: IndexItem, hour: int) -> tuple[int, int, int]:
|
||||
"""하기 좋은 시간이 가까운 각을 앞에, 오늘 시간이 지난 각을 뒤에."""
|
||||
ahead = [w for w in item.definition.windows or [] if w["to"] > hour]
|
||||
spans = [_span(w) for w in item.definition.windows or []]
|
||||
ahead = [(lo, hi) for lo, hi in spans if hi > hour]
|
||||
if not ahead:
|
||||
return 1, 0, item.rank
|
||||
return 0, min(max(0, w["from"] - hour) for w in ahead), item.rank
|
||||
return 0, min(max(0, lo - hour) for lo, _ in ahead), item.rank
|
||||
|
||||
|
||||
def _span(w: dict) -> tuple[int, int]:
|
||||
if w.get("around") == "sunset":
|
||||
return _SUNSET_HOUR - w.get("hours", 1), _SUNSET_HOUR + w.get("hours", 1) + 1
|
||||
return w["from"], w["to"]
|
||||
|
||||
|
||||
def _weekends(days: list[DayPlan]) -> list[list[DayPlan]]:
|
||||
"""예보가 있는 토·일을 주마다 묶는다. 다음 주말은 예보가 닿는 날(오늘+10일)부터 보인다."""
|
||||
out: dict[date, list[DayPlan]] = {}
|
||||
for d in days:
|
||||
if d.day.weekday() >= 5:
|
||||
out.setdefault(d.day - timedelta(days=d.day.weekday()), []).append(d)
|
||||
return list(out.values())
|
||||
|
||||
|
||||
def _spread(cards: list[PostData]) -> list[PostData]:
|
||||
@@ -155,8 +172,6 @@ async def build_feed_day(day: date, crud: FeedCRUD, season_crud: SeasonCRUD) ->
|
||||
end = start + timedelta(days=1)
|
||||
rows = []
|
||||
for position, post_type, ref_type, rank in LINEUP:
|
||||
if post_type is PostType.WEEK and day.weekday() < 3:
|
||||
continue
|
||||
ref = refs.get(post_type)
|
||||
if ref_type is RefType.ARTICLE and ref is None:
|
||||
continue
|
||||
@@ -335,13 +350,14 @@ class FeedService:
|
||||
slides=[RowsSlide(kind="rows", eyebrow=f"{c.region.name.split()[0]} 행사 · {e.status_label}", line=e.event.name, icon=e.event.icon, rows=rows)],
|
||||
share_messages=[f"{e.event.name} 같이 갈래?"])
|
||||
if t is PostType.WEEK and c.days:
|
||||
weekend = [d for d in c.days if d.day.weekday() >= 5][:2]
|
||||
if not weekend:
|
||||
weekends = _weekends(c.days)
|
||||
if not weekends:
|
||||
return None
|
||||
return PostData(**base, title="이번 주말 추천", icon="calendar", caption=" ".join(f"{d.weekday}요일은 {d.pick}." for d in weekend),
|
||||
slides=[WeekSlide(kind="week", eyebrow=f"이번 주말 · {c.region.short_name}", line=weekend[0].pick, days=[
|
||||
WeekDay(day=d.day, weekday=d.weekday, icon=d.icon, text=d.headline) for d in weekend
|
||||
])], share_messages=["이번 주말 같이 놀자 🙌"])
|
||||
first = weekends[0]
|
||||
return PostData(**base, title="이번 주말 추천", icon="calendar", caption=" ".join(f"{d.weekday}요일은 {d.pick}." for d in first),
|
||||
slides=[WeekSlide(kind="week", eyebrow=f"{label} · {c.region.short_name}", line=w[0].pick, days=[
|
||||
WeekDay(day=d.day, weekday=d.weekday, icon=d.icon, text=d.headline) for d in w
|
||||
]) for label, w in zip(("이번 주말", "다음 주말"), weekends)], share_messages=["이번 주말 같이 놀자 🙌"])
|
||||
if t is PostType.QUOTE:
|
||||
return self._quote(base, c)
|
||||
return None
|
||||
|
||||
Reference in new issue
Block a user