-
Notifications
You must be signed in to change notification settings - Fork 34
[volume-10] Collect, Stack, Zip #232
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
base: yeonsu00
Are you sure you want to change the base?
Changes from all commits
7fe86f3
3219edb
a8d0651
6db0d0b
5ef9c2c
9206eb2
8ce3935
4da5b86
6ce8ba3
bdbd9a9
8fbbdcd
af65e9c
de4d9cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package com.loopers.domain.ranking; | ||
|
|
||
| import com.loopers.domain.BaseEntity; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.Table; | ||
| import jakarta.persistence.UniqueConstraint; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| @Entity | ||
| @Table( | ||
| name = "mv_product_rank_monthly", | ||
| uniqueConstraints = { | ||
| @UniqueConstraint(columnNames = {"product_id", "period_start_date", "period_end_date"}) | ||
| } | ||
| ) | ||
| @Getter | ||
| public class MvProductRankMonthly extends BaseEntity { | ||
|
|
||
| @Column(name = "product_id", nullable = false) | ||
| private Long productId; | ||
|
|
||
| @Column(nullable = true) | ||
| private Integer ranking; | ||
|
|
||
| @Column(nullable = false) | ||
| private Double score; | ||
|
|
||
| @Column(name = "period_start_date", nullable = false) | ||
| private LocalDate periodStartDate; | ||
|
|
||
| @Column(name = "period_end_date", nullable = false) | ||
| private LocalDate periodEndDate; | ||
|
|
||
| @Column(name = "like_count", nullable = false) | ||
| private Long likeCount; | ||
|
|
||
| @Column(name = "view_count", nullable = false) | ||
| private Long viewCount; | ||
|
|
||
| @Column(name = "sales_count", nullable = false) | ||
| private Long salesCount; | ||
|
|
||
| @Builder | ||
| private MvProductRankMonthly(Long productId, Integer ranking, Double score, LocalDate periodStartDate, | ||
| LocalDate periodEndDate, Long likeCount, Long viewCount, Long salesCount) { | ||
| this.productId = productId; | ||
| this.ranking = ranking; | ||
| this.score = score; | ||
| this.periodStartDate = periodStartDate; | ||
| this.periodEndDate = periodEndDate; | ||
| this.likeCount = likeCount; | ||
| this.viewCount = viewCount; | ||
| this.salesCount = salesCount; | ||
| } | ||
|
|
||
| public MvProductRankMonthly() { | ||
| } | ||
|
|
||
| public static MvProductRankMonthly create(Long productId, Integer ranking, Double score, LocalDate periodStartDate, | ||
| LocalDate periodEndDate, Long likeCount, Long viewCount, Long salesCount) { | ||
| return MvProductRankMonthly.builder() | ||
| .productId(productId) | ||
| .ranking(ranking) | ||
| .score(score) | ||
| .periodStartDate(periodStartDate) | ||
| .periodEndDate(periodEndDate) | ||
| .likeCount(likeCount) | ||
| .viewCount(viewCount) | ||
| .salesCount(salesCount) | ||
| .build(); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.loopers.domain.ranking; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| public interface MvProductRankMonthlyRepository { | ||
| List<MvProductRankMonthly> findByPeriodOrderByRankingAsc(LocalDate periodStartDate, LocalDate periodEndDate, int page, int size); | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package com.loopers.domain.ranking; | ||
|
|
||
| import com.loopers.domain.BaseEntity; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.Table; | ||
| import jakarta.persistence.UniqueConstraint; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| @Entity | ||
| @Table( | ||
| name = "mv_product_rank_weekly", | ||
| uniqueConstraints = { | ||
| @UniqueConstraint(columnNames = {"product_id", "period_start_date", "period_end_date"}) | ||
| } | ||
| ) | ||
| @Getter | ||
| public class MvProductRankWeekly extends BaseEntity { | ||
|
|
||
| @Column(name = "product_id", nullable = false) | ||
| private Long productId; | ||
|
|
||
| @Column(nullable = true) | ||
| private Integer ranking; | ||
|
|
||
| @Column(nullable = false) | ||
| private Double score; | ||
|
|
||
| @Column(name = "period_start_date", nullable = false) | ||
| private LocalDate periodStartDate; | ||
|
|
||
| @Column(name = "period_end_date", nullable = false) | ||
| private LocalDate periodEndDate; | ||
|
|
||
| @Column(name = "like_count", nullable = false) | ||
| private Long likeCount; | ||
|
|
||
| @Column(name = "view_count", nullable = false) | ||
| private Long viewCount; | ||
|
|
||
| @Column(name = "sales_count", nullable = false) | ||
| private Long salesCount; | ||
|
|
||
| @Builder | ||
| private MvProductRankWeekly(Long productId, Integer ranking, Double score, LocalDate periodStartDate, LocalDate periodEndDate, | ||
| Long likeCount, Long viewCount, Long salesCount) { | ||
| this.productId = productId; | ||
| this.ranking = ranking; | ||
| this.score = score; | ||
| this.periodStartDate = periodStartDate; | ||
| this.periodEndDate = periodEndDate; | ||
| this.likeCount = likeCount; | ||
| this.viewCount = viewCount; | ||
| this.salesCount = salesCount; | ||
| } | ||
|
Comment on lines
+47
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋๋ฝ๋ ๋ฉ์๋:
๐ ๊ถ์ฅ ์์ ์ public MvProductRankWeekly() {
}
+ public void updateMetrics(Double score, Long likeCount, Long viewCount, Long salesCount) {
+ this.score = score;
+ this.likeCount = likeCount;
+ this.viewCount = viewCount;
+ this.salesCount = salesCount;
+ }
+
+ public void updateRanking(Integer ranking) {
+ this.ranking = ranking;
+ }
+
public static MvProductRankWeekly create(Long productId, Integer ranking, Double score, LocalDate periodStartDate,
|
||
|
|
||
| public MvProductRankWeekly() { | ||
| } | ||
|
|
||
| public static MvProductRankWeekly create(Long productId, Integer ranking, Double score, LocalDate periodStartDate, | ||
| LocalDate periodEndDate, Long likeCount, Long viewCount, Long salesCount) { | ||
| return MvProductRankWeekly.builder() | ||
| .productId(productId) | ||
| .ranking(ranking) | ||
| .score(score) | ||
| .periodStartDate(periodStartDate) | ||
| .periodEndDate(periodEndDate) | ||
| .likeCount(likeCount) | ||
| .viewCount(viewCount) | ||
| .salesCount(salesCount) | ||
| .build(); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.loopers.domain.ranking; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| public interface MvProductRankWeeklyRepository { | ||
| List<MvProductRankWeekly> findByPeriodOrderByRankingAsc(LocalDate periodStartDate, LocalDate periodEndDate, int page, int size); | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.loopers.domain.ranking; | ||
|
|
||
| import java.time.DayOfWeek; | ||
| import java.time.LocalDate; | ||
| import java.time.YearMonth; | ||
| import java.time.temporal.TemporalAdjusters; | ||
|
|
||
| public record RankingPeriod( | ||
| LocalDate startDate, | ||
| LocalDate endDate | ||
| ) { | ||
| public static RankingPeriod ofWeek(LocalDate date) { | ||
| LocalDate weekStart = date.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); | ||
| LocalDate weekEnd = date.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)); | ||
| return new RankingPeriod(weekStart, weekEnd); | ||
| } | ||
|
|
||
| public static RankingPeriod ofMonth(LocalDate date) { | ||
| YearMonth yearMonth = YearMonth.from(date); | ||
| LocalDate monthStart = yearMonth.atDay(1); | ||
| LocalDate monthEnd = yearMonth.atEndOfMonth(); | ||
| return new RankingPeriod(monthStart, monthEnd); | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.loopers.infrastructure.ranking; | ||
|
|
||
| import com.loopers.domain.ranking.MvProductRankMonthly; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| public interface MvProductRankMonthlyJpaRepository extends JpaRepository<MvProductRankMonthly, Long> { | ||
|
|
||
| List<MvProductRankMonthly> findByPeriodStartDateAndPeriodEndDateOrderByRankingAsc( | ||
| LocalDate periodStartDate, | ||
| LocalDate periodEndDate, | ||
| Pageable pageable | ||
| ); | ||
|
|
||
| } | ||
|
Comment on lines
+10
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐งฉ Analysis chain๐ Script executed: # Find the Weekly repository interface
fd -t f "MvProductRankWeeklyJpaRepository" --type=fileRepository: Loopers-dev-lab/loopers-spring-java-template Length of output: 299 ๐ Script executed: # Check the Monthly repository file mentioned in the review
cat "apps/commerce-api/src/main/java/com/loopers/infrastructure/ranking/MvProductRankMonthlyJpaRepository.java"Repository: Loopers-dev-lab/loopers-spring-java-template Length of output: 660 ๐ Script executed: # Search for all methods in the Weekly repository
rg "findByProductId" --type=java -A 5 | head -50Repository: Loopers-dev-lab/loopers-spring-java-template Length of output: 7308 ๐ Script executed: # Check for usage of Monthly repository's methods
rg "MvProductRankMonthlyJpaRepository" --type=java -A 3Repository: Loopers-dev-lab/loopers-spring-java-template Length of output: 3870 ๐ Script executed: cat "apps/commerce-api/src/main/java/com/loopers/infrastructure/ranking/MvProductRankMonthlyRepositoryImpl.java"Repository: Loopers-dev-lab/loopers-spring-java-template Length of output: 1087
์ด Monthly ์ ์ฅ์์์ ๋ชจ๋ ๊ฐ ์ธํฐํ์ด์ค ์ผ๊ด์ฑ์ ์ ์งํ๊ธฐ ์ํด ๋ค์ ๋ฉ์๋๋ฅผ ์ถ๊ฐํ์ธ์: Optional<MvProductRankMonthly> findByProductIdAndPeriodStartDateAndPeriodEndDate(
Long productId,
LocalDate periodStartDate,
LocalDate periodEndDate
);๐ค Prompt for AI Agents |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.loopers.infrastructure.ranking; | ||
|
|
||
| import com.loopers.domain.ranking.MvProductRankMonthly; | ||
| import com.loopers.domain.ranking.MvProductRankMonthlyRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class MvProductRankMonthlyRepositoryImpl implements MvProductRankMonthlyRepository { | ||
|
|
||
| private final MvProductRankMonthlyJpaRepository mvProductRankMonthlyJpaRepository; | ||
|
|
||
| @Override | ||
| public List<MvProductRankMonthly> findByPeriodOrderByRankingAsc(LocalDate periodStartDate, LocalDate periodEndDate, int page, int size) { | ||
| Pageable pageable = PageRequest.of(page - 1, size); | ||
| return mvProductRankMonthlyJpaRepository.findByPeriodStartDateAndPeriodEndDateOrderByRankingAsc(periodStartDate, periodEndDate, pageable); | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.loopers.infrastructure.ranking; | ||
|
|
||
| import com.loopers.domain.ranking.MvProductRankWeekly; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| public interface MvProductRankWeeklyJpaRepository extends JpaRepository<MvProductRankWeekly, Long> { | ||
|
|
||
| List<MvProductRankWeekly> findByPeriodStartDateAndPeriodEndDateOrderByRankingAsc( | ||
| LocalDate periodStartDate, | ||
| LocalDate periodEndDate, | ||
| Pageable pageable | ||
| ); | ||
| } | ||
|
|
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.
์ํฐํฐ์ ํ์ํ ์ ๋ฐ์ดํธ ๋ฉ์๋๊ฐ ๋๋ฝ๋์ด ์์ต๋๋ค.
MonthlyRankingService์์existing.updateMetrics(score, likeCount, viewCount, salesCount)์rank.updateRanking(i + 1)๋ฅผ ํธ์ถํ๋๋ฐ, ์ด ์ํฐํฐ์๋ ํด๋น ๋ฉ์๋๋ค์ด ์์ต๋๋ค. ์ด ๋ฉ์๋๋ค์ ์ถ๊ฐํด์ผ ํฉ๋๋ค.๐ ์ ์ํ๋ ์์
public MvProductRankMonthly() { } + public void updateMetrics(Double score, Long likeCount, Long viewCount, Long salesCount) { + this.score = score; + this.likeCount = likeCount; + this.viewCount = viewCount; + this.salesCount = salesCount; + } + + public void updateRanking(Integer ranking) { + this.ranking = ranking; + } + public static MvProductRankMonthly create(Long productId, Integer ranking, Double score, LocalDate periodStartDate,๐ค Prompt for AI Agents