-
Notifications
You must be signed in to change notification settings - Fork 44
[volume-10] Batch 기반 주간·월간 랭킹 시스템 구현 - 박시온 #416
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
hey-sion
wants to merge
7
commits into
Loopers-dev-lab:hey-sion
Choose a base branch
from
hey-sion:round10_batch
base: hey-sion
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5798ded
refactor: product_metrics 필드명 orderCount → orderLineCount 변경
hey-sion 69a356a
feat: 일별 상품 메트릭 집계 테이블(product_metrics_daily) 추가
hey-sion 3ab7043
feat: 주간/월간 랭킹 스냅샷 엔티티 및 레포지토리 추가
hey-sion be397e4
feat: 주간/월간 랭킹 집계 배치 잡 구현 (chunk 기반)
hey-sion 2f0b8a0
refactor: PaymentCompletedEventPayload에서 미사용 필드(userId, productIds) 제거
hey-sion 5bcf053
feat: 랭킹 API에 rankingType 파라미터 추가 (WEEKLY/MONTHLY 스냅샷 조회)
hey-sion d36da68
test: 배치 롤링 윈도우 경계 검증 테스트 추가 (WEEKLY 8일 전 / MONTHLY 31일 전 데이터 제외)
hey-sion 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
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
10 changes: 10 additions & 0 deletions
10
...erce-api/src/main/java/com/loopers/domain/ranking/ProductRankSnapshotQueryRepository.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,10 @@ | ||
| package com.loopers.domain.ranking; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public interface ProductRankSnapshotQueryRepository { | ||
| List<ProductRankSnapshot> findRankings(RankingType rankingType, LocalDate rankDate, int offset, int size); | ||
| Optional<LocalDate> findLatestRankDate(RankingType rankingType); | ||
| } |
43 changes: 43 additions & 0 deletions
43
.../main/java/com/loopers/infrastructure/ranking/ProductRankSnapshotQueryRepositoryImpl.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,43 @@ | ||
| package com.loopers.infrastructure.ranking; | ||
|
|
||
| import com.loopers.domain.ranking.ProductRankSnapshot; | ||
| import com.loopers.domain.ranking.ProductRankSnapshotQueryRepository; | ||
| import com.loopers.domain.ranking.RankingType; | ||
| import com.loopers.infrastructure.ranking.ProductRankSnapshotJpaRepository; | ||
| import jakarta.persistence.EntityManager; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Repository | ||
| public class ProductRankSnapshotQueryRepositoryImpl implements ProductRankSnapshotQueryRepository { | ||
|
|
||
| private final EntityManager entityManager; | ||
|
|
||
| @Override | ||
| public List<ProductRankSnapshot> findRankings(RankingType rankingType, LocalDate rankDate, int offset, int size) { | ||
| return entityManager.createQuery( | ||
| "SELECT p FROM ProductRankSnapshot p " + | ||
| "WHERE p.rankingType = :rankingType AND p.rankDate = :rankDate " + | ||
| "ORDER BY p.rankPosition ASC", ProductRankSnapshot.class) | ||
| .setParameter("rankingType", rankingType) | ||
| .setParameter("rankDate", rankDate) | ||
| .setFirstResult(offset) | ||
| .setMaxResults(size) | ||
| .getResultList(); | ||
| } | ||
|
|
||
| @Override | ||
| public Optional<LocalDate> findLatestRankDate(RankingType rankingType) { | ||
| List<LocalDate> result = entityManager.createQuery( | ||
| "SELECT MAX(p.rankDate) FROM ProductRankSnapshot p " + | ||
| "WHERE p.rankingType = :rankingType", LocalDate.class) | ||
| .setParameter("rankingType", rankingType) | ||
| .getResultList(); | ||
| return result.isEmpty() ? Optional.empty() : Optional.ofNullable(result.get(0)); | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rankingType입력이 잘못된 경우 표준 에러 포맷을 벗어난다.enum 바인딩 실패 시 Spring이
MethodArgumentTypeMismatchException을 던지고ApiControllerAdvice에서CoreException기반의 통일된 응답 포맷 대신 기본 500/400 포맷이 반환될 수 있다. 운영 관점에서 클라이언트가 에러 코드를 일관되게 처리하지 못하면 장애 재현·디버깅이 어렵다.수정안:
String으로 받은 뒤 도메인 규칙으로 검증하여CoreException(ErrorType.BAD_REQUEST, ...)로 변환하거나,@ControllerAdvice에 타입 미스매치 →CoreException매핑을 추가한다. 추가 테스트:rankingType=INVALID요청 시 400과 표준 에러 바디가 반환되는지 E2E로 검증한다.As per coding guidelines, "enforce unified error handling by routing errors through CoreException to ApiControllerAdvice to ensure a consistent response format".
🤖 Prompt for AI Agents