Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/grad_2025/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ async def search_grad_2025_posts(
str | None,
Query(description="Base64 인코딩된 커서 (응답의 next_cursor 값)"),
] = None,
category: Category | None = Query(None),
univ_major: str | None = Query(None),
categories: list[Category] | None = Query(default=None),
univ_majors: list[str] | None = Query(default=None),
) -> Page[PostCompactRead]:
decoded_cursor = Grad2025Cursor.decode(cursor)
return await grad_2025_service.search_posts(
cursor=decoded_cursor,
category=category,
univ_major=univ_major,
categories=categories,
univ_majors=univ_majors,
)
8 changes: 4 additions & 4 deletions app/grad_2025/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ async def search_posts(
*,
cursor: Grad2025Cursor | None,
limit: int = POST_CURSOR_LIMIT,
category: Category | None = None,
univ_major: str | None = None,
categories: list[Category] | None = None,
univ_majors: list[str] | None = None,
) -> Page[PostCompactRead]:
cursor_id = cursor.id if cursor else None
posts = await self.post_repository.find_grad_2025_posts(
cursor=cursor_id,
limit=limit,
category=category,
univ_major=univ_major,
categories=categories,
univ_majors=univ_majors,
)
compact_posts = [PostCompactRead.from_post(post) for post in posts]
next_cursor = (
Expand Down
12 changes: 6 additions & 6 deletions app/posts/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ async def find_grad_2025_posts(
*,
cursor: int | None,
limit: int,
category: Category | None = None,
univ_major: str | None = None,
categories: list[Category] | None = None,
univ_majors: list[str] | None = None,
) -> list[Post]:
"""post_grad_2025_table에 존재하는 Post만 조회합니다."""
stmt = (
Expand All @@ -315,13 +315,13 @@ async def find_grad_2025_posts(
)
)

if category is not None:
stmt = stmt.where(Post.category == category)
if categories is not None:
stmt = stmt.where(Post.category.in_(categories))

if univ_major is not None:
if univ_majors is not None:
stmt = stmt.join(
Grad2025, post_grad_2025_table.c.grad_2025_id == Grad2025.id
).where(Grad2025.name == univ_major)
).where(Grad2025.name.in_(univ_majors))

result = await self.session.scalars(stmt)
return list(result.unique().all())
Loading