-
Notifications
You must be signed in to change notification settings - Fork 44
[volume-10] Spring Batch 기반 주간/월간 랭킹 시스템 구현 #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
madirony
wants to merge
8
commits into
Loopers-dev-lab:madirony
Choose a base branch
from
madirony:volume-10
base: madirony
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2888695
feat(ranking): MV 엔티티 및 Repository 인터페이스 추가
madirony cb8f3d7
feat(batch): 주간/월간 랭킹 배치 Job 구현
madirony 48da3d6
feat(ranking): Ranking API에 주간/월간 period 분기 추가
madirony c812164
test(batch): 주간/월간 랭킹 배치 E2E 테스트 추가
madirony cc0591c
test(ranking): Ranking API E2E 테스트 추가
madirony 278cd9a
fix(test): 기존 깨진 테스트 3건 수정
madirony 6b85ee7
refactor(batch): Chunk-Oriented Reader → Processor → Writer 구조 복원
madirony 39f5dbe
fix: 랭킹 배치 안정성 개선 및 동시성 테스트 flaky 제거
madirony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
apps/commerce-api/src/main/java/com/loopers/application/ranking/MvRankingAppService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.loopers.application.ranking; | ||
|
|
||
| import com.loopers.domain.ranking.MvProductRankMonthly; | ||
| import com.loopers.domain.ranking.MvProductRankWeekly; | ||
| import com.loopers.domain.ranking.ProductRankMvRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class MvRankingAppService { | ||
|
|
||
| private final ProductRankMvRepository productRankMvRepository; | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public List<RankingEntry> getWeeklyRankings(String yearWeek, int page, int size) { | ||
| return productRankMvRepository.findWeeklyRankings(yearWeek, page, size).stream() | ||
| .map(mv -> new RankingEntry(mv.getRanking(), mv.getProductId(), mv.getScore())) | ||
| .toList(); | ||
| } | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public List<RankingEntry> getMonthlyRankings(String yearMonth, int page, int size) { | ||
| return productRankMvRepository.findMonthlyRankings(yearMonth, page, size).stream() | ||
| .map(mv -> new RankingEntry(mv.getRanking(), mv.getProductId(), mv.getScore())) | ||
| .toList(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...i/src/main/java/com/loopers/infrastructure/ranking/MvProductRankMonthlyJpaRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.loopers.infrastructure.ranking; | ||
|
|
||
| import com.loopers.domain.ranking.MvProductRankMonthly; | ||
| import com.loopers.domain.ranking.MvProductRankMonthlyId; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface MvProductRankMonthlyJpaRepository extends JpaRepository<MvProductRankMonthly, MvProductRankMonthlyId> { | ||
|
|
||
| List<MvProductRankMonthly> findByYearMonthOrderByRankingAsc(String yearMonth, Pageable pageable); | ||
|
|
||
| List<MvProductRankMonthly> findByYearMonthOrderByRankingAsc(String yearMonth); | ||
| } |
15 changes: 15 additions & 0 deletions
15
...pi/src/main/java/com/loopers/infrastructure/ranking/MvProductRankWeeklyJpaRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.loopers.infrastructure.ranking; | ||
|
|
||
| import com.loopers.domain.ranking.MvProductRankWeekly; | ||
| import com.loopers.domain.ranking.MvProductRankWeeklyId; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface MvProductRankWeeklyJpaRepository extends JpaRepository<MvProductRankWeekly, MvProductRankWeeklyId> { | ||
|
|
||
| List<MvProductRankWeekly> findByYearWeekOrderByRankingAsc(String yearWeek, Pageable pageable); | ||
|
|
||
| List<MvProductRankWeekly> findByYearWeekOrderByRankingAsc(String yearWeek); | ||
| } |
50 changes: 50 additions & 0 deletions
50
...rce-api/src/main/java/com/loopers/infrastructure/ranking/ProductRankMvRepositoryImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package com.loopers.infrastructure.ranking; | ||
|
|
||
| import com.loopers.domain.ranking.MvProductRankMonthly; | ||
| import com.loopers.domain.ranking.MvProductRankWeekly; | ||
| import com.loopers.domain.ranking.ProductRankMvRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class ProductRankMvRepositoryImpl implements ProductRankMvRepository { | ||
|
|
||
| private final MvProductRankWeeklyJpaRepository weeklyJpaRepository; | ||
| private final MvProductRankMonthlyJpaRepository monthlyJpaRepository; | ||
|
|
||
| @Override | ||
| public List<MvProductRankWeekly> findWeeklyRankings(String yearWeek, int page, int size) { | ||
| return weeklyJpaRepository.findByYearWeekOrderByRankingAsc(yearWeek, PageRequest.of(page, size)); | ||
| } | ||
|
|
||
| @Override | ||
| public List<MvProductRankMonthly> findMonthlyRankings(String yearMonth, int page, int size) { | ||
| return monthlyJpaRepository.findByYearMonthOrderByRankingAsc(yearMonth, PageRequest.of(page, size)); | ||
| } | ||
|
|
||
| @Override | ||
| public void saveAllWeekly(List<MvProductRankWeekly> rankings) { | ||
| weeklyJpaRepository.saveAll(rankings); | ||
| } | ||
|
|
||
| @Override | ||
| public void saveAllMonthly(List<MvProductRankMonthly> rankings) { | ||
| monthlyJpaRepository.saveAll(rankings); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteWeeklyByYearWeek(String yearWeek) { | ||
| List<MvProductRankWeekly> existing = weeklyJpaRepository.findByYearWeekOrderByRankingAsc(yearWeek); | ||
| weeklyJpaRepository.deleteAll(existing); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteMonthlyByYearMonth(String yearMonth) { | ||
| List<MvProductRankMonthly> existing = monthlyJpaRepository.findByYearMonthOrderByRankingAsc(yearMonth); | ||
| monthlyJpaRepository.deleteAll(existing); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.