Repository navigation
[Refactor/#160] 공지 커서 목록 쿼리를 하나로 통합 - #161
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
github-actions
Bot
requested review from
leegain1,
sangrae2325,
tnals0924 and
xeoxxn
October 22, 2026 09:47
tnals0924
approved these changes
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#️⃣연관된 이슈
🎯 해결하려는 문제가 무엇인가요?
공지 커서 목록이 첫 페이지용
findFirstSlice와 다음 페이지용findNextSlice두 쿼리로 나뉘어 있습니다. 카테고리 조건과 정렬은 같고 커서 조건만 다른데, 조건을 바꿀 때마다 두 곳을 똑같이 고쳐야 합니다. 물품 목록(ItemJpaRepository.findSlice)은 이미 커서 파라미터가null이면 첫 페이지로 동작하는 하나의 쿼리를 씁니다.❓ 왜 해결해야 하나요?
목록 조건(예: 제목 검색)을 추가하려면 두 쿼리를 함께 고쳐야 하고, 한쪽만 고치면 첫 페이지와 다음 페이지의 필터가 어긋납니다. 쿼리 하나로 모으면 이 위험이 사라집니다. 급한 작업은 아니고 유지 보수를 위한 정리입니다.
⭐ 어떻게 해결했나요?
NoticeJpaRepository:findFirstSlice/findNextSlice를findSlice하나로 합쳤습니다. 커서가 없으면(:cursorId IS NULL) 커서 조건이 빠져 첫 페이지가 되고, 있으면 기존과 같은 세 단계 키셋 조건(pinned→createdAt→id)으로 다음 페이지를 읽습니다. 카테고리 조건과 정렬은 그대로입니다.cursorPinned를Boolean으로:null을 받을 수 있게 기본형boolean에서 래퍼로 바꿨습니다.NoticeRepositoryImpl: 커서가 있으면pinned·createdAt·id를 풀어서, 없으면 세 값 모두null로findSlice를 한 번 호출합니다. 분기하던 삼항식이 사라집니다.동작을 바꾸지 않는 리팩토링입니다.
🧩 이 PR의 한계 & 트레이드오프
null로 바인딩한Boolean/LocalDateTime파라미터가IS NULL과 비교식에서 문제없는지는 dev에서 확인이 필요합니다. 물품 쿼리가 같은 패턴을 문자열·정수로 이미 쓰고 있어 위험은 낮다고 봅니다.cursorId만 보고 첫 페이지 여부를 정하므로, 세 값 중 일부만null인 호출은 의도와 다르게 동작합니다. 호출부(NoticeRepositoryImpl)가 항상 세 값을 함께 넘기도록 했고, 이 규칙은 쿼리 위 주석에 적었습니다.NoticeJpaRepository.java)에 관리자 목록search쿼리를 추가해서, 이 PR과 [Feat/#142] 게시판(공지) 관리자 API 보완 - 고정 여부 반영 및 동시 수정 제어 #143 중 나중에 머지되는 쪽이 이 파일의 충돌(서로 다른 쿼리를 나란히 두는 단순한 충돌)을 정리해야 합니다.⛓️ 기존 기능에 미치는 영향
NoticeJpaRepository(infrastructure:db내부)의 메서드가findFirstSlice/findNextSlice→findSlice로 바뀝니다. 이를 쓰는 곳은NoticeRepositoryImpl뿐입니다.🔀 Edge Case & 실패 시나리오
pinned가 같은 공지끼리createdAt이 같음id내림차순으로 구분 (기존과 동일)📋 검토한 대안과 선택 이유
ItemJpaRepository처럼 커서 값을 개별 파라미터null가드로 합치기(채택): 쿼리 하나로 모이고 물품과 같은 패턴입니다.Specification/QueryDSL 등 동적 쿼리: 이 정도 분기에 새 도구를 들이는 것은 과하다고 보고 제외했습니다.💬 리뷰 포인트
[r]합친 JPQL이 dev(MySQL)에서 정상 기동·조회되는지. 특히 첫 페이지(커서null)와 다음 페이지 모두[c]커서 세 값을 함께 넘겨야 한다는 전제를 쿼리 주석과 호출부에 두는 방식으로 충분한지[a]findSlice이름