feat: 오늘 피드 — 사람 글을 묶음 대신 포스트처럼 두 장마다 한 장씩(큰 카드·댓글), 행사는 띠 대신 축제 전부와 팝업·전시·공연 2개씩 포스트로
- 사람 글 큰 카드: 머리줄·4:5 본문(사진, 없으면 글을 크게)·좋아요·댓글·보내기 - 사람 글 댓글: 로그인한 사람만, comment 표에 talk_id, talk.comment_count (init.sql) - '오늘 내 글'·'동네 사람들'·주제별 묶음, '이번 주 가까운 행사' 띠 제거 - 행사 포스트 자리 최대 40개, 앞쪽 절반에 다 못 들어가면 끝까지 한 장씩 걸러 - GA: feed_item_view(talk·event 노출), talk_comment
This commit is contained in:
1 parent
f6cb6f2deb
commit
dba3d78f14
22 files changed
+653
-318
No files matched your search
@@ -195,6 +195,49 @@ def test_arrange_scatters_up_to_three_events_same_spot_all_day():
|
||||
assert run(14, "2026-10-02:1144000000") == out
|
||||
|
||||
|
||||
def test_feed_events_keeps_every_festival_and_two_of_other_kinds():
|
||||
from types import SimpleNamespace
|
||||
|
||||
from common.enums import EventKind
|
||||
from services.feed_service import feed_events
|
||||
from services.week_service import EventItem
|
||||
|
||||
kinds = [EventKind.POPUP] * 4 + [EventKind.FESTIVAL] * 6 + [EventKind.CONCERT] * 3 + [EventKind.EXHIBITION] * 3
|
||||
items = [EventItem(event=SimpleNamespace(kind=k.value, n=n), status="live", status_label="진행 중", fit=None) for n, k in enumerate(kinds)]
|
||||
out = [e.event.kind for e in feed_events(items)]
|
||||
assert out.count(EventKind.FESTIVAL.value) == 6
|
||||
assert all(out.count(k.value) == 2 for k in (EventKind.POPUP, EventKind.CONCERT, EventKind.EXHIBITION))
|
||||
assert out[:4] == [EventKind.FESTIVAL.value, EventKind.POPUP.value, EventKind.EXHIBITION.value, EventKind.CONCERT.value]
|
||||
|
||||
|
||||
def test_arrange_spreads_many_events_through_whole_feed():
|
||||
"""행사가 앞쪽 절반 자리보다 많으면 끝까지 한 장씩 걸러 끼우고, 남은 건 맨 뒤에 다 붙인다."""
|
||||
from datetime import datetime
|
||||
|
||||
from common.utils.kma_time import KST
|
||||
from services.feed_service import arrange
|
||||
|
||||
sunset = datetime(2026, 10, 2, 18, 10, tzinfo=KST)
|
||||
others = [PostType.WEATHER, PostType.GAK, PostType.GAK, PostType.GAK, PostType.SUNSET, PostType.WEEK, PostType.SEASON, PostType.TIP, PostType.QUOTE]
|
||||
cards = [_card(t, n) for n, t in enumerate(others + [PostType.EVENT] * 20)]
|
||||
out = arrange(cards, "day", datetime(2026, 10, 2, 13, tzinfo=KST), sunset, False, "2026-10-02:1144000000")
|
||||
types = [c.post_type for c in out]
|
||||
assert types.count(PostType.EVENT) == 20 and types[0] is PostType.WEATHER
|
||||
rest = len(others) - 1
|
||||
assert PostType.EVENT not in types[1:1 + 2 * rest:2] and types[2:2 + 2 * rest:2] == [PostType.EVENT] * rest
|
||||
assert set(types[1 + 2 * rest:]) == {PostType.EVENT}
|
||||
assert [c.post_id for c in out if c.post_type is PostType.EVENT] == list(range(len(others), len(others) + 20))
|
||||
|
||||
|
||||
def test_lineup_event_slots_stay_below_card_positions():
|
||||
from crud.card_crud import CARD_POSITION_START
|
||||
from services.feed_service import LINEUP, _EVENT_SLOTS
|
||||
|
||||
positions = [x[0] for x in LINEUP]
|
||||
assert len(positions) == len(set(positions)) and max(positions) < CARD_POSITION_START
|
||||
assert sorted(x[3] for x in LINEUP if x[1] is PostType.EVENT) == list(range(1, _EVENT_SLOTS + 1))
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_build_day_makes_every_card_at_three():
|
||||
thursday = date(2026, 10, 15)
|
||||
|
||||
Reference in new issue
Block a user