Skip to content

Conversation

@username1103
Copy link
Contributor

@username1103 username1103 commented Oct 22, 2025

resolve #110

Summary by CodeRabbit

  • 새로운 기능

    • Atlas Search 결과에 대한 페이지 매김 지원 추가 — 시퀀스 토큰과 이전/이후 검색 옵션(searchBefore/searchAfter)으로 결과 탐색 개선.
  • 테스트

    • 시퀀스 토큰 및 이전/이후 검색 옵션 동작을 검증하는 테스트 추가.

@coderabbitai
Copy link

coderabbitai bot commented Oct 22, 2025

📝 Walkthrough

Walkthrough

ProjectStageDsl에 searchSequenceToken(alias: String = "paginationToken") 메서드가 추가되고, SearchStageDsl에 nullable 속성 searchAfter와 searchBefore가 추가되었습니다. 관련 단위 테스트들이 각각 추가되어 새 필드와 메타데이터의 JSON 렌더링을 검증합니다.

Changes

집단 / 파일(들) 변경 요약
ProjectStageDsl 확장
core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/ProjectStageDsl.kt
searchSequenceToken(alias: String = "paginationToken") 메서드 추가 — 메타데이터 키 "searchSequenceToken"을 주어진 별칭으로 등록.
SearchStageDsl 확장
core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchStageDsl.kt
var searchAfter: String?var searchBefore: String? 속성 추가 — 비공개 필드 업데이트 및 값이 할당될 때 문서에 "searchAfter"/"searchBefore" 키로 기록됨.
테스트: ProjectStageDsl
core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/ProjectStageDslTest.kt
searchSequenceToken("alias") 호출 시 출력되는 $project JSON에 META "searchSequenceToken"이 지정된 별칭 아래에 렌더링되는지 검증하는 테스트 추가.
테스트: SearchStageDsl
core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchStageDslTest.kt
searchAftersearchBefore 설정 시 생성되는 Search 스테이지 JSON에 각각 "searchAfter": "token" / "searchBefore": "token"이 포함되는지 검증하는 테스트 블록 추가.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as 개발자 코드
  participant DSL as SearchStageDsl / ProjectStageDsl
  participant Mongo as Atlas Search

  Dev->>DSL: searchAfter = "token" / searchBefore = "token"
  note right of DSL #DDEBF7: SearchStageDsl가 내부 문서에\n"searchAfter"/"searchBefore" 키 설정
  Dev->>DSL: project.searchSequenceToken("alias")
  note right of DSL #F6F8E6: ProjectStageDsl가 메타\n"searchSequenceToken"을 등록
  DSL->>Mongo: Aggregation pipeline 포함된 search stage\n(contains searchAfter/searchBefore, project meta)
  Mongo-->>DSL: Search 결과(페이징 가능 토큰 포함)
Loading

코드 리뷰 예상 소요 시간

🎯 2 (간단함) | ⏱️ ~12분

시 (詩)

🐰 토큰 따라 숲을 달려,
After와 Before로 길을 잡네.
메타를 새긴 작은 깃발 하나,
페이지가 이어지고 또 이어지네.
DSL의 당근 한 조각, 냠냠 ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed PR 제목 "feat: add search pagination operation"은 변경사항의 핵심을 정확하게 반영합니다. 변경된 모든 파일은 검색 페이지네이션 기능 추가와 직접적으로 관련되어 있으며, searchSequenceToken, searchAfter, searchBefore 같은 페이지네이션 관련 API가 추가되었습니다. 제목은 명확하고 간결하며 주요 변경사항을 충분히 설명하고 있습니다.
Linked Issues Check ✅ Passed #110 이슈의 목표는 MongoDB Atlas Search 페이지네이션을 searchAfter 문법을 사용하여 구현하는 것입니다. PR의 변경사항이 이를 충족하는지 확인하면, SearchStageDsl에 searchAfter와 searchBefore 속성이 추가되어 페이지네이션 쿼리 구성을 지원하고, ProjectStageDsl에 searchSequenceToken 메서드가 추가되어 페이지네이션 토큰을 처리합니다. 또한 이러한 기능들에 대한 테스트 케이스가 포함되어 있어 요구사항을 충분히 만족합니다.
Out of Scope Changes Check ✅ Passed 모든 변경사항이 #110에서 명시한 검색 페이지네이션 구현과 직접적으로 관련되어 있습니다. SearchStageDsl의 searchAfter/searchBefore, ProjectStageDsl의 searchSequenceToken 추가, 그리고 해당하는 테스트 케이스들이 모두 이 목표를 중심으로 추가되었으며, 범위를 벗어난 변경사항은 없습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchStageDsl.kt (1)

73-82: 구현이 올바르며, 선택적 개선 사항을 고려해보세요.

searchBefore 속성이 기존 패턴을 잘 따르고 있습니다.

MongoDB Atlas Search에서 searchAftersearchBefore는 일반적으로 상호 배타적입니다(각각 순방향/역방향 페이지네이션에 사용). 두 속성을 동시에 설정할 경우 의도하지 않은 동작이 발생할 수 있습니다. 필요하다면 setter에서 상호 배타성 검증을 추가하는 것을 고려해볼 수 있지만, MongoDB가 이를 자체적으로 처리할 수 있다면 현재 구현도 충분합니다.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 64dc49f and d031b8b.

📒 Files selected for processing (4)
  • core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/ProjectStageDsl.kt (1 hunks)
  • core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchStageDsl.kt (1 hunks)
  • core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/ProjectStageDslTest.kt (1 hunks)
  • core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchStageDslTest.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/ProjectStageDsl.kt
🔇 Additional comments (4)
core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchStageDslTest.kt (2)

261-282: 테스트 구현이 올바릅니다!

searchAfter 옵션 테스트가 기존 테스트 패턴을 잘 따르고 있으며, JSON 출력 검증이 정확합니다.


284-305: 테스트 구현이 올바릅니다!

searchBefore 옵션 테스트가 기존 테스트 패턴을 잘 따르고 있으며, JSON 출력 검증이 정확합니다.

core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/ProjectStageDslTest.kt (1)

248-271: 테스트 구현이 올바릅니다!

searchSequenceToken 메타 프로젝션 테스트가 기존의 다른 메타 필드 테스트(searchScore, searchScoreDetails 등)와 동일한 패턴을 따르고 있으며, Atlas Search 페이지네이션 토큰 처리를 위한 올바른 JSON 구조를 검증하고 있습니다.

core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchStageDsl.kt (1)

62-71: 구현이 올바릅니다!

searchAfter 속성이 기존 속성들(index, returnStoredSource 등)과 동일한 패턴을 따르고 있으며, KDoc에 MongoDB 공식 문서 링크가 포함되어 있어 좋습니다.

@hong3-inflab hong3-inflab merged commit 28b9aaf into inflearn:main Oct 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Search Pagination Results

3 participants