feat: 총동연 피드 랭킹 스냅샷 조회 API 추가 및 가중치 계산 중복 제거#404
Conversation
- 총동연 피드 랭킹 스냅샷 조회 API (GET /ranking/snapshot) 추가 - 가중치 점수 계산 로직을 공통 메서드로 추출하여 중복 제거 - 스냅샷 조회 관련 테스트 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
Walkthrough클럽 피드 랭킹 스냅샷을 조회하는 새로운 API 엔드포인트 및 관련 서비스 메서드를 추가합니다. FeedMonthlyRanking 스냅샷 데이터를 저장소에서 조회하여 ClubFeedRankingQuery로 매핑하는 새로운 데이터 경로를 구현합니다. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.java (1)
98-104: 가중치 총점 계산식을 한 곳으로 더 모으면 유지보수가 쉬워집니다.현재 총점 계산이 별도 메서드에도 남아 있어, 가중치 변경 시 식 불일치 위험이 있습니다.
♻️ 제안 diff
+ private long calculateTotalScore(long feedCount, long viewCount, long likeCount, long commentCount) { + return feedCount * FEED_WEIGHT + + viewCount * VIEW_WEIGHT + + likeCount * LIKE_WEIGHT + + commentCount * COMMENT_WEIGHT; + } + private ClubFeedRankingQuery toClubFeedRankingQuery(int rank, Long clubId, String clubName, long feedCount, long viewCount, long likeCount, long commentCount) { long feedScore = feedCount * FEED_WEIGHT; long viewScore = viewCount * VIEW_WEIGHT; long likeScore = likeCount * LIKE_WEIGHT; long commentScore = commentCount * COMMENT_WEIGHT; - long totalScore = feedScore + viewScore + likeScore + commentScore; + long totalScore = calculateTotalScore(feedCount, viewCount, likeCount, commentCount); return ClubFeedRankingQuery.of(rank, clubId, clubName, feedScore, viewScore, likeScore, commentScore, totalScore); } @@ private long calculateScore(MonthlyFeedRankingDto rawRanking) { - return rawRanking.getFeedCount() * FEED_WEIGHT - + rawRanking.getViewCount() * VIEW_WEIGHT - + rawRanking.getLikeCount() * LIKE_WEIGHT - + rawRanking.getCommentCount() * COMMENT_WEIGHT; + return calculateTotalScore( + rawRanking.getFeedCount(), + rawRanking.getViewCount(), + rawRanking.getLikeCount(), + rawRanking.getCommentCount()); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.java` around lines 98 - 104, toClubFeedRankingQuery에서 feedScore/viewScore/likeScore/commentScore와 totalScore를 개별로 계산하는 대신 가중치 총점 계산식을 공통 메서드로 분리해 유지보수성을 높이세요: 새로 computeTotalScore(long feedCount,long viewCount,long likeCount,long commentCount) 또는 ScoreCalculator 클래스(또는 static 유틸)를 만들고 FEED_WEIGHT, VIEW_WEIGHT, LIKE_WEIGHT, COMMENT_WEIGHT를 이용해 단일 식으로 totalScore를 반환하도록 구현한 뒤 toClubFeedRankingQuery는 해당 메서드로 totalScore를 받아 사용하도록 바꾸세요; 이 방식은 다른 위치에서도 동일한 메서드를 호출하게 해 가중치 변경 시 중복 수정을 방지합니다.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.java`:
- Around line 98-104: toClubFeedRankingQuery에서
feedScore/viewScore/likeScore/commentScore와 totalScore를 개별로 계산하는 대신 가중치 총점 계산식을
공통 메서드로 분리해 유지보수성을 높이세요: 새로 computeTotalScore(long feedCount,long viewCount,long
likeCount,long commentCount) 또는 ScoreCalculator 클래스(또는 static 유틸)를 만들고
FEED_WEIGHT, VIEW_WEIGHT, LIKE_WEIGHT, COMMENT_WEIGHT를 이용해 단일 식으로 totalScore를
반환하도록 구현한 뒤 toClubFeedRankingQuery는 해당 메서드로 totalScore를 받아 사용하도록 바꾸세요; 이 방식은 다른
위치에서도 동일한 메서드를 호출하게 해 가중치 변경 시 중복 수정을 방지합니다.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/main/java/ddingdong/ddingdongBE/domain/feed/api/AdminFeedApi.javasrc/main/java/ddingdong/ddingdongBE/domain/feed/controller/AdminFeedController.javasrc/main/java/ddingdong/ddingdongBE/domain/feed/repository/FeedMonthlyRankingRepository.javasrc/main/java/ddingdong/ddingdongBE/domain/feed/service/FeedRankingService.javasrc/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.javasrc/test/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingServiceTest.java
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
🚀 작업 내용
GET /ranking/snapshot)🤔 고민했던 내용
score필드를 totalScore로 직접 사용하는 방안도 있지만, 개별 가중치 점수(feedScore, viewScore 등)를 계산하는 과정에서 totalScore도 자연스럽게 산출되므로 공통 메서드에서 일관되게 계산하는 것이 더 명확하다고 판단했습니다💬 리뷰 중점사항
🤖 Generated with Claude Code
Summary by CodeRabbit
릴리스 노트
새로운 기능
테스트