Skip to content
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

Merged
merged 31 commits into from
Aug 30, 2023
Merged

feat 통계 로직 추가 #190

merged 31 commits into from
Aug 30, 2023

Conversation

jjungsk
Copy link
Collaborator

@jjungsk jjungsk commented Aug 30, 2023

♻️ 변경 사항

  • 매일 00:00:00 하루 판매량, 판매액, 클릭 수, 노출 수 통계 로직 실행

🎸 기타

closes #149

# 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
Copy link
Member

@whatasame whatasame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

바쁘신 와중에 원시값 포장까지 하시고 정말 고생하셨습니다!

피드백은 나중에 반영해주세요 ㅎㅎ

Comment on lines +31 to +32
@EmbeddedId
private StatisticsId statisticsId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

식별자를 복합키로 하신 이유가 궁금합니다!

현재 상태에선 년, 월, 주, 일, 상품 id로 구분하는데 만약 12시간마다 통계를 구해야한다면 난감해질 것 같아요.

개인적으로 식별자는 linear하게 증가하는 정수를 선호하는 편입니다.

Comment on lines +58 to +66
@Builder
public Statistics(
final Region region,
final BrewType brewType,
final Impression impression,
final Click click,
final SaleQuantity saleQuantity,
final SalePrice salePrice
) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

디미터의 법칙을 역으로 적용해서 생성자 또한 내부 자료 구조를 드러내지 않는 건 어떨까요?

생성자의 인자를 원시값으로 받고 내부에서 VO를 생성해주면 좋을 것 같아요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분은 프로젝트 하면서 아직도 저도 주관이 확실하게 잡히지 않은 부분입니다..!!
뭐가 좋을까요 정말!?

Copy link
Member

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을 생성하는 방법이 좋다..고 저의 철학을 세웠습니다.

"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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

함수명은 update인데 실제 query는 insert네요. 예상가능한 이름을 가졌으면 좋을 것 같아요.

또 어떤 query를 수행하는 메서드인지도 조금은 드러났으면 좋겠어요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 update와 insert를 동시에 하고 있습니다 어떻게 정의해야 좋을지 저도 명확한 기준이 서지 않네요ㅜ

Copy link
Member

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/main/resources/application-dev.yml Outdated Show resolved Hide resolved
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class StatisticsId implements Serializable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serializable을 구현한 이유가 있을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EmbeddedId 를 구현하는 @embeddable 객체의 경우 Searilzable 이 필요하다고 했는데 공식문서로 확인한것이 아니라 틀릴 수도 있겠군요! 확인해 보겠쑵니다~!

Copy link
Collaborator Author

@jjungsk jjungsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 리뷰 부분은 빠른 시일내에 수정할게요^^

Comment on lines +58 to +66
@Builder
public Statistics(
final Region region,
final BrewType brewType,
final Impression impression,
final Click click,
final SaleQuantity saleQuantity,
final SalePrice salePrice
) {
Copy link
Collaborator Author

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(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 update와 insert를 동시에 하고 있습니다 어떻게 정의해야 좋을지 저도 명확한 기준이 서지 않네요ㅜ

src/main/resources/application-dev.yml Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Aug 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 23 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

warning 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.
Read more here

@jjungsk jjungsk merged commit e8a44b4 into develop Aug 30, 2023
3 checks passed
Copy link
Member

@whatasame whatasame left a 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(
Copy link
Member

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 같은데 설명 부탁드려요!

Comment on lines +58 to +66
@Builder
public Statistics(
final Region region,
final BrewType brewType,
final Impression impression,
final Click click,
final SaleQuantity saleQuantity,
final SalePrice salePrice
) {
Copy link
Member

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을 생성하는 방법이 좋다..고 저의 철학을 세웠습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: 쿼리 성능 개선
2 participants