Skip to content

feat: 총동연 피드 랭킹 스냅샷 조회 API 추가 및 가중치 계산 중복 제거#404

Merged
KoSeonJe merged 2 commits intodevelopfrom
feat/feed-ranking-snapshot-api
Mar 2, 2026
Merged

feat: 총동연 피드 랭킹 스냅샷 조회 API 추가 및 가중치 계산 중복 제거#404
KoSeonJe merged 2 commits intodevelopfrom
feat/feed-ranking-snapshot-api

Conversation

@KoSeonJe
Copy link
Copy Markdown
Collaborator

@KoSeonJe KoSeonJe commented Mar 1, 2026

🚀 작업 내용

  • 총동연이 특정 연/월의 피드 랭킹 스냅샷을 조회할 수 있는 API를 추가했습니다 (GET /ranking/snapshot)
  • 코드리뷰 반영: 실시간 랭킹 변환과 스냅샷 랭킹 변환에서 가중치 점수 계산 로직이 중복되어 있어, raw count를 직접 받는 공통 메서드를 추출하고 두 메서드가 위임하도록 리팩토링했습니다

🤔 고민했던 내용

  • 스냅샷 엔티티의 score 필드를 totalScore로 직접 사용하는 방안도 있지만, 개별 가중치 점수(feedScore, viewScore 등)를 계산하는 과정에서 totalScore도 자연스럽게 산출되므로 공통 메서드에서 일관되게 계산하는 것이 더 명확하다고 판단했습니다

💬 리뷰 중점사항

  • 공통 메서드 추출 후 기존 동작이 변경되지 않았는지 확인 부탁드립니다

🤖 Generated with Claude Code

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 클럽 피드 랭킹 스냅샷을 조회하는 새로운 API 엔드포인트 추가. 기존 랭킹 엔드포인트와 동일한 연도 및 월 파라미터로 조회 가능.
  • 테스트

    • 스냅샷 조회 기능에 대한 테스트 케이스 추가. 랭킹 정렬, 빈 결과, 가중치 점수 계산 검증 포함.

- 총동연 피드 랭킹 스냅샷 조회 API (GET /ranking/snapshot) 추가
- 가중치 점수 계산 로직을 공통 메서드로 추출하여 중복 제거
- 스냅샷 조회 관련 테스트 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3f6cc5 and 239f4b9.

📒 Files selected for processing (2)
  • src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.java
  • src/test/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingServiceTest.java

Walkthrough

클럽 피드 랭킹 스냅샷을 조회하는 새로운 API 엔드포인트 및 관련 서비스 메서드를 추가합니다. FeedMonthlyRanking 스냅샷 데이터를 저장소에서 조회하여 ClubFeedRankingQuery로 매핑하는 새로운 데이터 경로를 구현합니다.

Changes

Cohort / File(s) Summary
API 및 Controller 계층
src/main/java/ddingdong/ddingdongBE/domain/feed/api/AdminFeedApi.java, src/main/java/ddingdong/ddingdongBE/domain/feed/controller/AdminFeedController.java
GET /ranking/snapshot 엔드포인트 추가, 년도와 월 파라미터로 스냅샷 조회 지원, OpenAPI 문서화 포함
Service 계층
src/main/java/ddingdong/ddingdongBE/domain/feed/service/FeedRankingService.java, src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.java
getClubFeedRankingSnapshot() 메서드 선언 및 구현 추가, FeedMonthlyRanking 스냅샷 조회 및 매핑 로직 구현, toClubFeedRankingQueryFromSnapshot() 매퍼 추가
테스트
src/test/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingServiceTest.java
스냅샷 조회 기능에 대한 3가지 테스트 케이스 추가 (랭킹 순서, 빈 결과, 가중치 점수 계산)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • wonjunYou
  • 5uhwann
  • Seooooo24
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 PR의 주요 변경사항을 명확하게 요약하고 있습니다: 피드 랭킹 스냅샷 조회 API 추가와 가중치 계산 중복 제거를 간결하게 표현했습니다.
Description check ✅ Passed PR 설명이 템플릿의 모든 필수 섹션(작업 내용, 고민했던 내용, 리뷰 중점사항)을 포함하며 충분한 정보를 제공하고 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/feed-ranking-snapshot-api

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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
Copy Markdown

@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.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3dd7bb9 and d3f6cc5.

📒 Files selected for processing (6)
  • src/main/java/ddingdong/ddingdongBE/domain/feed/api/AdminFeedApi.java
  • src/main/java/ddingdong/ddingdongBE/domain/feed/controller/AdminFeedController.java
  • src/main/java/ddingdong/ddingdongBE/domain/feed/repository/FeedMonthlyRankingRepository.java
  • src/main/java/ddingdong/ddingdongBE/domain/feed/service/FeedRankingService.java
  • src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.java
  • src/test/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingServiceTest.java

@github-actions github-actions bot added the D-3 label Mar 2, 2026
@KoSeonJe KoSeonJe merged commit 997425a into develop Mar 2, 2026
1 of 2 checks passed
@KoSeonJe KoSeonJe deleted the feat/feed-ranking-snapshot-api branch March 2, 2026 13:21
@KoSeonJe KoSeonJe self-assigned this Mar 3, 2026
KoSeonJe added a commit that referenced this pull request Mar 16, 2026
@KoSeonJe KoSeonJe mentioned this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant