feat: 이달의 현황 API lastMonthRank를 스냅샷 단건 조회로 변경#405
Conversation
지난달 순위 조회 시 전체 클럽 피드를 재계산하던 방식에서 FeedMonthlyRanking 스냅샷 테이블 단건 조회로 변경하여 성능 개선 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughFeedMonthlyRankingRepository에 두 개의 조회 메서드를 추가하고, GeneralFeedRankingService의 지난달 랭킹 조회를 인메모리 필터링에서 FeedMonthlyRankingRepository 직접 조회로 변경했으며, 관련 테스트들을 스냅샷 기반 데이터 설정으로 업데이트했습니다. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
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)
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.
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
📒 Files selected for processing (3)
src/main/java/ddingdong/ddingdongBE/domain/feed/repository/FeedMonthlyRankingRepository.javasrc/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingService.javasrc/test/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingServiceTest.java
| return feedMonthlyRankingRepository | ||
| .findByClubIdAndTargetYearAndTargetMonth(clubId, lastYear, lastMonth) | ||
| .map(FeedMonthlyRanking::getRanking) |
There was a problem hiding this comment.
컴파일 에러를 유발하는 의존성/심볼 누락이 있습니다.
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.
src/test/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedRankingServiceTest.java
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🚀 작업 내용
이달의 현황 API에서 지난달 순위(
lastMonthRank)를 조회할 때 매번 전체 클럽의 피드 데이터를 조회해 가중치를 재계산하던 방식을, 이미 저장된FeedMonthlyRanking스냅샷 테이블에서 해당 클럽의 순위만 단건 조회하도록 변경했습니다.🤔 고민했던 내용
getClubFeedRanking(lastYear, lastMonth)를 호출해 모든 클럽의 피드를 조회하고 가중치를 계산한 뒤 해당 클럽만 필터링하는 비효율적인 구조였습니다.💬 리뷰 중점사항
FeedMonthlyRankingRepository에 추가한findByClubIdAndTargetYearAndTargetMonth메서드가 적절한지🤖 Generated with Claude Code
Summary by CodeRabbit
릴리즈 노트
개선사항
테스트