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(server) : 정산금액을 계산해서 갱신하는 기능을 스케줄러에 등록한다. (#439) #440

Merged
merged 7 commits into from Oct 8, 2021

Conversation

DWL5
Copy link
Collaborator

@DWL5 DWL5 commented Oct 7, 2021

  • 매월 1일 00:00시에 스케줄러를 등록
  • 정산 금액을 계산하는 SQL추가
  • AdminService에 calculateExchangeAmount에 해당 로직이 들어있음!

제안

  • MemberService의 exchange()를 requestExchange로 변경하면 어떤지,,

close #440

@DWL5 DWL5 self-assigned this Oct 7, 2021
@DWL5 DWL5 added this to the TYF-SPRINT8 (for Launching) milestone Oct 7, 2021
@DWL5 DWL5 requested review from Joyykim and Be-poz October 7, 2021 08:53
@DWL5 DWL5 added feature 새로 추가될 기능 server 백엔드 관련 이슈 labels Oct 7, 2021
@DWL5 DWL5 linked an issue Oct 7, 2021 that may be closed by this pull request
@DWL5 DWL5 requested a review from Rok93 October 7, 2021 08:54
Copy link
Collaborator

@Be-poz Be-poz left a comment

Choose a reason for hiding this comment

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

이거야

.calculateExchangeAmountFromDonation(exchange.getMember(), exchange.getExchangeOn());
exchange.registerExchangeAmount(exchangeAmount);
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Be-poz 그런데 회원마다 업데이트 되는 금액이 다른데 벌크 업데이트가 가능한거야?
전에 근로 때도 내가 정책 정할 일이 있었는데, 잘 몰라서 이거 bulk update 하는게 어떻냐구 했다가.... 잘 안돼서 작업자가 고생했거든

@DWL5
Copy link
Collaborator Author

DWL5 commented Oct 7, 2021

벌크성 쿼리로 업데이트 하는 것 찾아봤는데
위의 예제 처럼 age를 1증가 시키는 것 처럼, 어떠한 데이터들을 한번에 공통된 처리를 할 때 벌크성 업데이트를 사용하는 듯 ㅜ

exchange id별로 exchange amount를 다르게 업데이트 할 경우에는 적용이 불가능 한 것 같아!

그래서 우선 계산 쿼리를 한번 날리고, 이후에 각각 exchange를 update 하는 식으로 변경했어!
계산 쿼리 후 exchange id와 amount를 가져오려고 ExchangeAmountDto를 만들었어!

JPA가 익숙치 않아서 이게 맞는지 더 좋은 방법이 있는지 잘 모르겠어 ㅜ
피드백 부탁할게!

Copy link
Collaborator

@Rok93 Rok93 left a comment

Choose a reason for hiding this comment

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

크게 코멘트 달 부분은 없는 것 같아
스케쥴러 공부 간단하게 했는데 충분히 어떤 작업을 했는지 알 수 있는 것 같고,
벌크 업데이트 부분은 가능한건지 잘 모르겠어, 일괄적으로 동일한 금액을 업데이트해주는거면 모르겠는데, 각 exchange 마다 다른 금액이 update 되는 거잖아 ? 이런 경우도 벌크 업데이트가 가능한건가? (대상 지정은 Where in 으로 두면 될 것 같은데....)

이건 @Be-poz 파즈한테 질문하고싶은건데!!
혹시 QueryDsl로 동적으로(?) 벌크 업데이트가 가능한 방법이 있을까?

코멘트에 달아둔 수리 의견에 대해서는

MemberService의 exchange()를 requestExchange로 변경하면 어떤지,,

이 부분은 사실 난 exchange()도 충분하다고 생각해 exchange를 동사로 보냐 명사로 보냐의 차이라고 생각하는데, 우리 서비스에서 exchange를 하나의 객체이자 Entity로 가지고 있어서 수리의 말도 일리가 있다고 생각하는데, 정산한다는 의미로도 충분히 의미가 전달된다고 생각해

import java.util.List;

public interface ExchangeQueryRepository {
List<ExchangeAmountDto> calculateExchangeAmountFromDonation(YearMonth exchangeOn);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
List<ExchangeAmountDto> calculateExchangeAmountFromDonation(YearMonth exchangeOn);
List<ExchangeAmountDto> calculateExchangeAmountFromDonation(YearMonth exchangeOn);

다른 클래스들처럼 첫 줄은 띄우면 좋을 것 같아! 😃

.calculateExchangeAmountFromDonation(exchange.getMember(), exchange.getExchangeOn());
exchange.registerExchangeAmount(exchangeAmount);
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Be-poz 그런데 회원마다 업데이트 되는 금액이 다른데 벌크 업데이트가 가능한거야?
전에 근로 때도 내가 정책 정할 일이 있었는데, 잘 몰라서 이거 bulk update 하는게 어떻냐구 했다가.... 잘 안돼서 작업자가 고생했거든

@Be-poz
Copy link
Collaborator

Be-poz commented Oct 8, 2021

이건 @Be-poz 파즈한테 질문하고싶은건데!! 혹시 QueryDsl로 동적으로(?) 벌크 업데이트가 가능한 방법이 있을까?
그런데 회원마다 업데이트 되는 금액이 다른데 벌크 업데이트가 가능한거야?

이게 지금 문제! 수리 말대로 update를 한 번에 동일한 값을 조정하는데 써야될 것 같아서... 지금의 경우는 회원마다 각기 다른 값 들을 넣어야 해서 문제가 되는 것 같아! insert table(...) values( ...) ; 이렇게 update도 대량으로 할 수 있는 방법이 있나 한 번 보구있엇어 일단 못찾앗으 ㅜ

@Joyykim Joyykim changed the title feat(server) : 정산금액 계산을 스케줄러에 등록한다. (#439) feat(server) : 정산금액을 계산해서 갱신하는 기능을 스케줄러에 등록한다. (#439) Oct 8, 2021
@Joyykim Joyykim merged commit 16eeb77 into develop Oct 8, 2021
@Joyykim Joyykim deleted the feat/exchange-scheduling branch October 8, 2021 06:39
@DWL5
Copy link
Collaborator Author

DWL5 commented Oct 8, 2021

  • exchange amount 계산 쿼리 한번
  • select exchange select 쿼리 한번
  • update문 만 exchange 개수 별로 수행

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 새로 추가될 기능 server 백엔드 관련 이슈
Projects
None yet
Development

Successfully merging this pull request may close these issues.

정산금액 계산을 스케줄러에 등록한다.
4 participants