-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat 통계 로직 추가 #190
feat 통계 로직 추가 #190
Conversation
# Conflicts: # src/main/java/com/woowacamp/soolsool/core/statistics/controller/StatisticsController.java # src/main/java/com/woowacamp/soolsool/core/statistics/domain/Statistics.java # src/main/java/com/woowacamp/soolsool/core/statistics/repository/StatisticsRepository.java # src/main/java/com/woowacamp/soolsool/core/statistics/service/StatisticsService.java
… into feature/149
… into feature/149
… into feature/149
… into feature/149
… into feature/149
… into feature/149 merge
… into feature/149 merge
… into feature/149
… into feature/149 merge
… into feature/149 merge
… into feature/149 merge
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.
바쁘신 와중에 원시값 포장까지 하시고 정말 고생하셨습니다!
피드백은 나중에 반영해주세요 ㅎㅎ
src/main/java/com/woowacamp/soolsool/core/statistics/controller/StatisticsController.java
Show resolved
Hide resolved
@EmbeddedId | ||
private StatisticsId statisticsId; |
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.
식별자를 복합키로 하신 이유가 궁금합니다!
현재 상태에선 년, 월, 주, 일, 상품 id로 구분하는데 만약 12시간마다 통계를 구해야한다면 난감해질 것 같아요.
개인적으로 식별자는 linear하게 증가하는 정수를 선호하는 편입니다.
@Builder | ||
public Statistics( | ||
final Region region, | ||
final BrewType brewType, | ||
final Impression impression, | ||
final Click click, | ||
final SaleQuantity saleQuantity, | ||
final SalePrice salePrice | ||
) { |
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.
디미터의 법칙을 역으로 적용해서 생성자 또한 내부 자료 구조를 드러내지 않는 건 어떨까요?
생성자의 인자를 원시값으로 받고 내부에서 VO를 생성해주면 좋을 것 같아요.
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.
이 부분은 프로젝트 하면서 아직도 저도 주관이 확실하게 잡히지 않은 부분입니다..!!
뭐가 좋을까요 정말!?
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.
Statistic
에서 StatisticClick
을 가지고 있을 때 Statistic
을 사용하는 쪽에서 StatisticClick
의 존재를 알아서는 안된다고 생각하는데요.
반대로 생성하는 쪽에서도 StatisticClick
의 존재를 알아서 안된다고 생각해요. 따라서 StatisticClick
의 원시값을 인자로 넘겨주고 내부에서 StatisticClick
을 생성하는 방법이 좋다..고 저의 철학을 세웠습니다.
src/main/java/com/woowacamp/soolsool/core/statistics/domain/StatisticsId.java
Show resolved
Hide resolved
src/main/java/com/woowacamp/soolsool/core/statistics/domain/Statistics.java
Show resolved
Hide resolved
"AND o.created_at BETWEEN :startDate AND :endDate " + | ||
"GROUP BY year, month, week, day, liquor_id, brew_type, region " + | ||
"ON DUPLICATE KEY UPDATE sale_quantity = (SELECT sale_quantity), sale_price = (SELECT sale_price) ", nativeQuery = true) | ||
void updateStatisticsSales( |
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.
함수명은 update인데 실제 query는 insert네요. 예상가능한 이름을 가졌으면 좋을 것 같아요.
또 어떤 query를 수행하는 메서드인지도 조금은 드러났으면 좋겠어요.
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.
현재 update와 insert를 동시에 하고 있습니다 어떻게 정의해야 좋을지 저도 명확한 기준이 서지 않네요ㅜ
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.
ON DUPLICATE KEY UPDATE sale_quantity = (SELECT sale_quantity), sale_price = (SELECT sale_price)
이 부분이 update 같은데 설명 부탁드려요!
src/test/java/com/woowacamp/soolsool/core/statistics/domain/StatisticsTest.java
Outdated
Show resolved
Hide resolved
src/main/java/com/woowacamp/soolsool/core/statistics/service/StatisticsService.java
Show resolved
Hide resolved
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Embeddable | ||
public class StatisticsId implements Serializable { |
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.
Serializable
을 구현한 이유가 있을까요?
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.
@EmbeddedId 를 구현하는 @embeddable 객체의 경우 Searilzable 이 필요하다고 했는데 공식문서로 확인한것이 아니라 틀릴 수도 있겠군요! 확인해 보겠쑵니다~!
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.
해당 리뷰 부분은 빠른 시일내에 수정할게요^^
src/main/java/com/woowacamp/soolsool/core/statistics/controller/StatisticsController.java
Show resolved
Hide resolved
src/main/java/com/woowacamp/soolsool/core/statistics/domain/Statistics.java
Show resolved
Hide resolved
src/main/java/com/woowacamp/soolsool/core/statistics/domain/Statistics.java
Show resolved
Hide resolved
@Builder | ||
public Statistics( | ||
final Region region, | ||
final BrewType brewType, | ||
final Impression impression, | ||
final Click click, | ||
final SaleQuantity saleQuantity, | ||
final SalePrice salePrice | ||
) { |
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.
이 부분은 프로젝트 하면서 아직도 저도 주관이 확실하게 잡히지 않은 부분입니다..!!
뭐가 좋을까요 정말!?
src/main/java/com/woowacamp/soolsool/core/statistics/domain/StatisticsId.java
Show resolved
Hide resolved
src/main/java/com/woowacamp/soolsool/core/statistics/domain/vo/BrewType.java
Show resolved
Hide resolved
src/main/java/com/woowacamp/soolsool/core/statistics/repository/StatisticsRepository.java
Show resolved
Hide resolved
"AND o.created_at BETWEEN :startDate AND :endDate " + | ||
"GROUP BY year, month, week, day, liquor_id, brew_type, region " + | ||
"ON DUPLICATE KEY UPDATE sale_quantity = (SELECT sale_quantity), sale_price = (SELECT sale_price) ", nativeQuery = true) | ||
void updateStatisticsSales( |
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.
현재 update와 insert를 동시에 하고 있습니다 어떻게 정의해야 좋을지 저도 명확한 기준이 서지 않네요ㅜ
src/main/java/com/woowacamp/soolsool/core/statistics/service/StatisticsService.java
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! 0 Bugs 0.0% Coverage The version of Java (11.0.20.1) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17. |
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.
답변 확인해주세요~
"AND o.created_at BETWEEN :startDate AND :endDate " + | ||
"GROUP BY year, month, week, day, liquor_id, brew_type, region " + | ||
"ON DUPLICATE KEY UPDATE sale_quantity = (SELECT sale_quantity), sale_price = (SELECT sale_price) ", nativeQuery = true) | ||
void updateStatisticsSales( |
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.
ON DUPLICATE KEY UPDATE sale_quantity = (SELECT sale_quantity), sale_price = (SELECT sale_price)
이 부분이 update 같은데 설명 부탁드려요!
@Builder | ||
public Statistics( | ||
final Region region, | ||
final BrewType brewType, | ||
final Impression impression, | ||
final Click click, | ||
final SaleQuantity saleQuantity, | ||
final SalePrice salePrice | ||
) { |
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.
Statistic
에서 StatisticClick
을 가지고 있을 때 Statistic
을 사용하는 쪽에서 StatisticClick
의 존재를 알아서는 안된다고 생각하는데요.
반대로 생성하는 쪽에서도 StatisticClick
의 존재를 알아서 안된다고 생각해요. 따라서 StatisticClick
의 원시값을 인자로 넘겨주고 내부에서 StatisticClick
을 생성하는 방법이 좋다..고 저의 철학을 세웠습니다.
♻️ 변경 사항
🎸 기타
closes #149