Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ddingdong.ddingdongBE.domain.feed.entity.FeedMonthlyRanking;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;

public interface FeedMonthlyRankingRepository extends JpaRepository<FeedMonthlyRanking, Long> {
Expand All @@ -10,4 +11,10 @@ public interface FeedMonthlyRankingRepository extends JpaRepository<FeedMonthlyR

List<FeedMonthlyRanking> findAllByTargetYearAndTargetMonthAndRanking(
int targetYear, int targetMonth, int ranking);

List<FeedMonthlyRanking> findAllByTargetYearAndTargetMonthOrderByRankingAsc(
int targetYear, int targetMonth);

Optional<FeedMonthlyRanking> findByClubIdAndTargetYearAndTargetMonth(
Long clubId, int targetYear, int targetMonth);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.club.service.ClubService;
import ddingdong.ddingdongBE.domain.feed.entity.FeedMonthlyRanking;
import ddingdong.ddingdongBE.domain.feed.repository.FeedMonthlyRankingRepository;
import ddingdong.ddingdongBE.domain.feed.repository.FeedRepository;
import ddingdong.ddingdongBE.domain.feed.repository.dto.MonthlyFeedRankingDto;
import ddingdong.ddingdongBE.domain.feed.service.dto.query.ClubFeedRankingQuery;
Expand All @@ -24,6 +26,7 @@ public class GeneralFeedRankingService implements FeedRankingService {
private static final int COMMENT_WEIGHT = 5;

private final FeedRepository feedRepository;
private final FeedMonthlyRankingRepository feedMonthlyRankingRepository;
private final ClubService clubService;

@Override
Expand Down Expand Up @@ -73,12 +76,9 @@ private int getLastMonthRank(Long clubId, int year, int month) {
int lastYear = month == 1 ? year - 1 : year;
int lastMonth = month == 1 ? 12 : month - 1;

List<ClubFeedRankingQuery> lastMonthRankings = getClubFeedRanking(lastYear, lastMonth);
return lastMonthRankings.stream()
.filter(ranking -> ranking.clubId().equals(clubId))
.filter(ranking -> ranking.totalScore() > 0)
.findFirst()
.map(ClubFeedRankingQuery::rank)
return feedMonthlyRankingRepository
.findByClubIdAndTargetYearAndTargetMonth(clubId, lastYear, lastMonth)
.map(FeedMonthlyRanking::getRanking)
Comment on lines +79 to +81
Copy link
Copy Markdown

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.

.orElse(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

import ddingdong.ddingdongBE.common.fixture.ClubFixture;
import ddingdong.ddingdongBE.common.fixture.FeedFixture;
import ddingdong.ddingdongBE.common.fixture.FeedMonthlyRankingFixture;
import ddingdong.ddingdongBE.common.fixture.UserFixture;
import ddingdong.ddingdongBE.common.support.TestContainerSupport;
import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.club.repository.ClubRepository;
import ddingdong.ddingdongBE.domain.feed.entity.Feed;
import ddingdong.ddingdongBE.domain.feed.repository.FeedCommentRepository;
import ddingdong.ddingdongBE.domain.feed.repository.FeedMonthlyRankingRepository;
import ddingdong.ddingdongBE.domain.feed.repository.FeedRepository;
import ddingdong.ddingdongBE.domain.feed.service.dto.query.ClubFeedRankingQuery;
import ddingdong.ddingdongBE.domain.feed.service.dto.query.ClubMonthlyStatusQuery;
Expand Down Expand Up @@ -41,6 +43,9 @@ class GeneralFeedRankingServiceTest extends TestContainerSupport {
@Autowired
private FeedCommentRepository feedCommentRepository;

@Autowired
private FeedMonthlyRankingRepository feedMonthlyRankingRepository;

@Autowired
private UserRepository userRepository;

Expand Down Expand Up @@ -280,18 +285,17 @@ void getClubMonthlyStatus_rankAccuracy() {
});
}

@DisplayName("동아리 이달의 현황 조회 - 성공: 저번 달에 피드가 있으면 lastMonthRank가 반환된다")
@DisplayName("동아리 이달의 현황 조회 - 성공: 저번 달 스냅샷이 있으면 lastMonthRank가 반환된다")
@Test
void getClubMonthlyStatus_withLastMonthRank() {
// given
User user = userRepository.save(UserFixture.createClubUser());
Club club = clubRepository.save(ClubFixture.createClub(user));

// 저번 달 피드 생성
// 저번 달 스냅샷 저장
LocalDate lastMonth = LocalDate.now().minusMonths(1);
Feed lastMonthFeed = feedRepository.save(FeedFixture.createImageFeed(club, "저번달 피드"));
jdbcTemplate.update("UPDATE feed SET created_at = ? WHERE id = ?",
Timestamp.valueOf(lastMonth.atStartOfDay()), lastMonthFeed.getId());
feedMonthlyRankingRepository.save(FeedMonthlyRankingFixture.createWithRanking(
club.getId(), club.getName(), lastMonth.getYear(), lastMonth.getMonthValue(), 1));

// 이번 달 피드 생성
feedRepository.save(FeedFixture.createImageFeed(club, "이번달 피드"));
Expand All @@ -302,7 +306,7 @@ void getClubMonthlyStatus_withLastMonthRank() {
// when
ClubMonthlyStatusQuery result = feedRankingService.getClubMonthlyStatus(user.getId(), year, month);

// then — 저번 달에도 피드가 있으므로 lastMonthRank > 0
// then — 저번 달 스냅샷이 있으므로 lastMonthRank > 0
assertSoftly(softly -> {
softly.assertThat(result.rank()).isEqualTo(1);
softly.assertThat(result.lastMonthRank()).isEqualTo(1);
Expand Down Expand Up @@ -336,11 +340,10 @@ void getClubMonthlyStatus_noCurrentMonthFeed_butHasLastMonthRank() {
User user = userRepository.save(UserFixture.createClubUser());
Club club = clubRepository.save(ClubFixture.createClub(user));

// 저번 달 피드만 생성 (이번 달 피드 없음)
// 저번 달 스냅샷만 저장 (이번 달 피드 없음)
LocalDate lastMonth = LocalDate.now().minusMonths(1);
Feed lastMonthFeed = feedRepository.save(FeedFixture.createImageFeed(club, "저번달 피드"));
jdbcTemplate.update("UPDATE feed SET created_at = ? WHERE id = ?",
Timestamp.valueOf(lastMonth.atStartOfDay()), lastMonthFeed.getId());
feedMonthlyRankingRepository.save(FeedMonthlyRankingFixture.createWithRanking(
club.getId(), club.getName(), lastMonth.getYear(), lastMonth.getMonthValue(), 1));

int year = LocalDate.now().getYear();
int month = LocalDate.now().getMonthValue();
Expand All @@ -363,11 +366,11 @@ void getClubMonthlyStatus_januaryLooksAtDecember() {
User user = userRepository.save(UserFixture.createClubUser());
Club club = clubRepository.save(ClubFixture.createClub(user));

// 전년도 12월 피드 생성
int currentYear = LocalDate.now().getYear();
Feed decemberFeed = feedRepository.save(FeedFixture.createImageFeed(club, "12월 피드"));
jdbcTemplate.update("UPDATE feed SET created_at = ? WHERE id = ?",
Timestamp.valueOf(LocalDateTime.of(currentYear - 1, 12, 15, 10, 0)), decemberFeed.getId());

// 전년도 12월 스냅샷 저장
feedMonthlyRankingRepository.save(FeedMonthlyRankingFixture.createWithRanking(
club.getId(), club.getName(), currentYear - 1, 12, 1));

// 1월 피드 생성
Feed januaryFeed = feedRepository.save(FeedFixture.createImageFeed(club, "1월 피드"));
Expand Down