feat: 각 점수를 아침·낮·저녁·밤 구간별로 — 지금 구간 점수로 순위, 구간이 안 겹치는 각은 순위·피드에서 빼고 목록 끝에

This commit is contained in:
minaChoi committed 2026-10-08 17:07:26 +09:00
1 parent ffc330d478
commit d6525f592c
12 files changed
+226 -40

No files matched your search

+7 -3
View File
@@ -60,8 +60,12 @@ async def test_index_list_ranks_all_34_with_today_tomorrow_weekend_trend(fakes):
assert body["result"]["success"] is True
assert len(body["items"]) == 34 and len(body["top3"]) == 3
priority = {d["code"]: d["priority"] for d in _seed()}
weighted = [rank_score(i["score"], priority[i["code"]]) for i in body["items"]]
assert weighted == sorted(weighted, reverse=True)
# 지금 구간에 해당하는 각이 먼저(순위), 해당 없는 각은 그 뒤. 각 묶음 안에서는 점수 × 중요도 순
actives = [i["active"] for i in body["items"]]
assert actives == sorted(actives, reverse=True) and all(i["active"] for i in body["top3"])
for group in (True, False):
weighted = [rank_score(i["score"], priority[i["code"]]) for i in body["items"] if i["active"] is group]
assert weighted == sorted(weighted, reverse=True)
today = now_kst().date()
for i in body["items"]:
assert [t["label"] for t in i["trend"]] == [slot_label(d, today) for d in slot_days(today)]
@@ -123,7 +127,7 @@ async def test_board_ranks_by_score_times_priority_weight(monkeypatch):
SimpleNamespace(index_id=2, code="mid", priority=2),
SimpleNamespace(index_id=3, code="high", priority=1),
]
scores = [SimpleNamespace(index_id=x, score_date=today, score=v) for x, v in ((1, 90), (2, 80), (3, 70))]
scores = [SimpleNamespace(index_id=x, score_date=today, score=v, slots={}) for x, v in ((1, 90), (2, 80), (3, 70))]
crud = SimpleNamespace(definitions=lambda s: _async(defs), scores=lambda s, *a: _async(scores))
service = IndexService(RegionCRUD(), crud, None, None, None, None, None, None)
monkeypatch.setattr(service, "ensure", lambda *a: _async((ErrorType.SUCCESS, 50)))