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

[refactor] 랭크 스케줄러 수정 #488

Merged
merged 4 commits into from
Mar 27, 2024
Merged

Conversation

Hju95
Copy link
Collaborator

@Hju95 Hju95 commented Mar 27, 2024

PR을 보내기 전에 확인해주세요!!

  • 컨벤션에 맞게 작성했습니다. 컨벤션 확인은 여기
  • 변경 사항에 대한 테스트를 했습니다.

관련 이슈

close: #487

개요

랭크 스케줄러를 돌리면 랭킹 매긴 답변들의 modify 가 변경되면서 화면에 (수정됨) 으로 표시됨

상세 내용

  • 랭크 스케줄러로 인해 답변이 (수정됨) 으로 바뀌는 현상 -> 엔티티 타지 않고 바로 repository 로 update

* 랭크 스케줄러로 인해 답변이 (수정됨) 으로 바뀌는 현상
-> 엔티티 타지 않고 바로 repository 로 update
@Hju95 Hju95 added the Refactor 코드 리팩토링 label Mar 27, 2024
@Hju95 Hju95 self-assigned this Mar 27, 2024

alertService.sendToBroker(alertDtoMapper.from(AlertDto.RankAnswerAlert.of(question, answer, rank)));
answerRepository.updateAnswerRank(rank, answer.getId());
Copy link
Collaborator

Choose a reason for hiding this comment

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

레포지토리 메서드를 바로 호출하기 보단 answerStore 사용 가능하십니까? ㅎㅎ

Copy link
Collaborator Author

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 +33
@Modifying
@Query("UPDATE Answer a SET a.rank = :rank WHERE a.id = :answerId")
void updateAnswerRank(@Param("rank") Rank rank, @Param("answerId") Long answerId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Answer 엔티티에 UpdateRank 방식으로 수정하는 방법은 생각해보셨나요?

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
Collaborator

Choose a reason for hiding this comment

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

Answer 엔티티에 UpdateRank 방식으로 수정하는 방법은 생각해보셨나요?

이렇게 하면 답변 랭킹 산정 과정에서 modifiedDate가 변경되어 화면에서 수정됨이 뜨게 되는 문제가 있었습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

아아 알겠습니다

@@ -24,6 +25,11 @@ public Answer store(Answer answer) {
return answerRepository.save(answer);
}

@Override
public void upRank(Rank rank, Long answerId) {
answerRepository.updateAnswerRank(rank, answerId);
Copy link
Member

Choose a reason for hiding this comment

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

왜 내부 로직이랑 메서드 이름이 다르죠?

Copy link
Collaborator

@mooncw mooncw Mar 27, 2024

Choose a reason for hiding this comment

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

제가 병룡님 대신 혼쭐 내드렸습니다 ^-^

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

반영했습니다..!

@Hju95 Hju95 merged commit adaf51c into develop Mar 27, 2024
1 check passed
@Hju95 Hju95 deleted the feat/#487-rank_no_change_modify branch March 27, 2024 06:18
mooncw pushed a commit that referenced this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor 코드 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[refactor] 랭킹 배치 후 화면에 (편집됨) 표시 안나오도록 수정
4 participants