-
Notifications
You must be signed in to change notification settings - Fork 0
fix: #5/issue pagination in cafe module #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes refactor the pagination logic in the Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant S as CafeService
participant R as CafeRepository
participant DB as Database
C->>S: Request swipe cafe list with query (page, take, etc.)
S->>R: getSwipeCafeList(user uuid, query)
R->>DB: Query cafes using query.page and query.take
DB-->>R: Return query results
R-->>S: Return formatted response with hasNextPage
S-->>C: Return results with nextPage calculated as query.page + 1
Assessment against linked issues
Possibly related PRs
Poem
Tip 🌐 Web search-backed reviews and chat
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (3)
src/cafe/cafe.service.ts (1)
126-136: Consider adding error handling for database operation.While the code structure is good, it's missing error handling for the database operation.
const { data, hasNextPage } = await this.cafeRepository.getSwipeCafeList( user.uuid, query, - ); + ).catch((error) => { + throw new BadRequestException('Failed to fetch cafe list: ' + error.message); + });src/cafe/cafe.repository.ts (2)
112-114: Consider removing redundant variable declarations.The local variables
pageandtakeare unnecessary since they're used only once.- const page = query.page; - const take = query.take; - - const skip = (page - 1) * take; + const skip = (query.page - 1) * query.take;
141-145: Consider adding a comment explaining the hasNextPage logic.The hasNextPage implementation is correct but could benefit from a clearer explanation.
let hasNextPage = false; if (rawResult.length > take) { hasNextPage = true; - rawResult.pop(); // 마지막 1개는 실제 응답으로 내려주지 않음 + rawResult.pop(); // Remove the extra item used to determine if there's a next page }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/cafe/cafe.repository.ts(1 hunks)src/cafe/cafe.service.ts(1 hunks)src/cafe/dto/req/getSwipeCafeList.dto.ts(1 hunks)
🔇 Additional comments (5)
src/cafe/dto/req/getSwipeCafeList.dto.ts (1)
15-15: LGTM! Well-structured pagination defaults.The default values for pagination parameters are well-chosen and properly documented. The validation and transformation decorators ensure type safety.
Also applies to: 25-25
src/cafe/cafe.service.ts (2)
110-115: LGTM! Proper GPS validation.The GPS coordinate validation is well-placed and provides clear error messages.
117-124: LGTM! Comprehensive pagination validation.The validation checks for page and take parameters are thorough and provide clear error messages.
src/cafe/cafe.repository.ts (2)
44-46: Consider prioritizing the performance TODOs.The TODOs highlight important performance considerations:
- SPATIAL INDEX implementation
- Potential MongoDB migration
- Performance testing
These should be tracked and prioritized.
Would you like me to create issues to track these performance improvements?
119-139: LGTM! Well-structured SQL query with proper pagination.The SQL query effectively combines:
- Distance-based filtering
- User preference filtering
- Pagination with LIMIT/OFFSET
- Proper ordering for consistent pagination
Cafe Module에서 평가 대상 카페 리스트를 불러오는 함수에 Pagination이 정상적으로 적용되지 않는 이슈 해결.
close #5
Summary by CodeRabbit