Skip to content

feat: 이달의 현황 API lastMonthRank를 스냅샷 단건 조회로 변경#405

Merged
KoSeonJe merged 2 commits intodevelopfrom
refactor/feed-monthly-status-snapshot-lookup
Mar 2, 2026
Merged

feat: 이달의 현황 API lastMonthRank를 스냅샷 단건 조회로 변경#405
KoSeonJe merged 2 commits intodevelopfrom
refactor/feed-monthly-status-snapshot-lookup

Conversation

@KoSeonJe
Copy link
Collaborator

@KoSeonJe KoSeonJe commented Mar 1, 2026

🚀 작업 내용

이달의 현황 API에서 지난달 순위(lastMonthRank)를 조회할 때 매번 전체 클럽의 피드 데이터를 조회해 가중치를 재계산하던 방식을, 이미 저장된 FeedMonthlyRanking 스냅샷 테이블에서 해당 클럽의 순위만 단건 조회하도록 변경했습니다.

🤔 고민했던 내용

  • 기존 방식은 getClubFeedRanking(lastYear, lastMonth)를 호출해 모든 클럽의 피드를 조회하고 가중치를 계산한 뒤 해당 클럽만 필터링하는 비효율적인 구조였습니다.
  • 스냅샷 테이블에 이미 지난달 랭킹이 저장되어 있으므로 단건 조회로 충분합니다.

💬 리뷰 중점사항

  • FeedMonthlyRankingRepository에 추가한 findByClubIdAndTargetYearAndTargetMonth 메서드가 적절한지
  • 테스트에서 지난달 피드 백데이트 방식을 스냅샷 직접 저장 방식으로 변경한 부분

🤖 Generated with Claude Code

Summary by CodeRabbit

릴리즈 노트

  • 개선사항

    • 월별 랭킹 조회 로직 개선 — 지난달 랭킹을 저장된 스냅샷에서 직접 조회하도록 변경하여 정확성과 성능 향상
    • 월별 상태 계산에서 지난달 순위 처리 방식 간소화
  • 테스트

    • 지난달 랭킹 스냅샷을 반영하도록 관련 단위 테스트 및 설명 업데이트

지난달 순위 조회 시 전체 클럽 피드를 재계산하던 방식에서
FeedMonthlyRanking 스냅샷 테이블 단건 조회로 변경하여 성능 개선

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

coderabbitai bot commented Mar 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ 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 68709e3 and ac5f032.

📒 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
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingServiceTest.java

Walkthrough

FeedMonthlyRankingRepository에 두 개의 조회 메서드를 추가하고, GeneralFeedRankingService의 지난달 랭킹 조회를 인메모리 필터링에서 FeedMonthlyRankingRepository 직접 조회로 변경했으며, 관련 테스트들을 스냅샷 기반 데이터 설정으로 업데이트했습니다.

Changes

Cohort / File(s) Summary
저장소 인터페이스 확장
src/main/java/ddingdong/ddingdongBE/domain/feed/repository/FeedMonthlyRankingRepository.java
특정 연·월의 전체 랭킹을 순위 순으로 반환하는 메서드(findAllByTargetYearAndTargetMonthOrderByRankingAsc)와 클럽 별 특정 연·월 랭킹을 조회하는 메서드(findByClubIdAndTargetYearAndTargetMonth) 추가.
서비스 로직 변경
src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.java
지난달 랭킹을 기존의 피드 리스트 필터링 및 스트림 처리 대신 FeedMonthlyRankingRepository의 Optional 조회로 바꿔 제어 흐름을 단순화함.
테스트 업데이트
src/test/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingServiceTest.java
테스트에서 지난달 데이터 생성 방식을 직접 피드 생성/타임스탬프 조작에서 feedMonthlyRankingRepository.save를 이용한 스냅샷 기반 설정으로 대체하고, 관련 DisplayName/주석을 "스냅샷"으로 갱신.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

🎯리팩토링

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 lastMonthRank를 스냅샷 단건 조회로 변경'이라는 제목은 기존 방식(전체 클럽 피드 조회)에서 새로운 방식(스냅샷 단건 조회)으로의 변경을 간결하고 구체적으로 표현합니다.
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 refactor/feed-monthly-status-snapshot-lookup

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.java`:
- Around line 76-78: GeneralFeedRankingService fails to compile because
feedMonthlyRankingRepository is not declared/initialized and FeedMonthlyRanking
is not resolved; add a properly-typed repository field (e.g., private final
FeedMonthlyRankingRepository feedMonthlyRankingRepository) and include it in the
service constructor for constructor injection (or annotate with `@Autowired` if
your project uses field injection), and add the missing import for the
FeedMonthlyRanking class; ensure the repository interface name matches your
codebase and update the class-level imports so references to FeedMonthlyRanking
and feedMonthlyRankingRepository resolve.

In
`@src/test/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingServiceTest.java`:
- Around line 292-293: The test fails to compile because
feedMonthlyRankingRepository and FeedMonthlyRankingFixture are referenced but
not imported or injected in GeneralFeedRankingServiceTest; add the necessary
import for FeedMonthlyRankingFixture and declare/inject/mock a
FeedMonthlyRankingRepository field used by the tests (e.g., a `@Mock` or
`@Autowired` field named feedMonthlyRankingRepository) so calls like
feedMonthlyRankingRepository.save(...) compile; update the test class imports
and setup/mocking initialization (e.g., MockitoAnnotations.openMocks or test
framework equivalent) so the three occurrences (lines referencing
feedMonthlyRankingRepository and FeedMonthlyRankingFixture) build successfully.

ℹ️ 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 68709e3.

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

Comment on lines +76 to +78
return feedMonthlyRankingRepository
.findByClubIdAndTargetYearAndTargetMonth(clubId, lastYear, lastMonth)
.map(FeedMonthlyRanking::getRanking)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

컴파일 에러를 유발하는 의존성/심볼 누락이 있습니다.

Line 76의 feedMonthlyRankingRepository와 Line 78의 FeedMonthlyRanking 참조가 현재 파일에서 해석되지 않아 빌드가 깨집니다. 리포지토리 필드 주입과 참조 방식 정리가 필요합니다.

수정 예시
 import ddingdong.ddingdongBE.domain.club.entity.Club;
 import ddingdong.ddingdongBE.domain.club.service.ClubService;
+import ddingdong.ddingdongBE.domain.feed.repository.FeedMonthlyRankingRepository;
 import ddingdong.ddingdongBE.domain.feed.repository.FeedRepository;
 import ddingdong.ddingdongBE.domain.feed.repository.dto.MonthlyFeedRankingDto;
@@
     private final FeedRepository feedRepository;
+    private final FeedMonthlyRankingRepository feedMonthlyRankingRepository;
     private final ClubService clubService;
@@
         return feedMonthlyRankingRepository
                 .findByClubIdAndTargetYearAndTargetMonth(clubId, lastYear, lastMonth)
-                .map(FeedMonthlyRanking::getRanking)
+                .map(ranking -> ranking.getRanking())
                 .orElse(0);
🧰 Tools
🪛 GitHub Actions: build-test.yml

[error] 76-76: cannot find symbol: variable feedMonthlyRankingRepository. This may indicate the field is not defined or not properly injected.


[error] 78-78: cannot find symbol: FeedMonthlyRanking. This may indicate a missing class, import, or incorrect reference.

🤖 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 76 - 78, GeneralFeedRankingService fails to compile because
feedMonthlyRankingRepository is not declared/initialized and FeedMonthlyRanking
is not resolved; add a properly-typed repository field (e.g., private final
FeedMonthlyRankingRepository feedMonthlyRankingRepository) and include it in the
service constructor for constructor injection (or annotate with `@Autowired` if
your project uses field injection), and add the missing import for the
FeedMonthlyRanking class; ensure the repository interface name matches your
codebase and update the class-level imports so references to FeedMonthlyRanking
and feedMonthlyRankingRepository resolve.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the D-3 label Mar 2, 2026
@KoSeonJe KoSeonJe merged commit 4f0c980 into develop Mar 2, 2026
2 checks passed
@KoSeonJe KoSeonJe deleted the refactor/feed-monthly-status-snapshot-lookup branch March 2, 2026 13:19
@KoSeonJe KoSeonJe changed the title refactor: 이달의 현황 API lastMonthRank를 스냅샷 단건 조회로 변경 feat: 이달의 현황 API lastMonthRank를 스냅샷 단건 조회로 변경 Mar 2, 2026
@KoSeonJe KoSeonJe self-assigned this Mar 3, 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