-
Notifications
You must be signed in to change notification settings - Fork 2
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/#461 같은 멤버가 등록중인 노래에 같은 부분을 킬링파트로 등록시 추가 데이터를 저장하지 않는 기능 구현 #469
Conversation
생성자 변경으로 인해 실패하는 테스트 수정, sql 스크립트에 해당 변경 내용 적용
|
||
private Member findMemberThrowIfNotExist(final Long memberId) { | ||
return memberRepository.findById(memberId) | ||
.orElseThrow(MemberNotExistException::new); |
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.
MemberException.MemberNotExistException
과 같이 바꿔주세요~!
final Map<String, String> errorProperties = Map.of("VotingSongId", String.valueOf(votingSongId)); | ||
return new VotingSongException.VotingSongNotExistException(errorProperties); |
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.
💬 예외를 던질 때, 바로 Map을 주입했던 기존 코드에서는 어떤 식으로 예외를 던지는지 한 번 더 들어가봐야 되더라구요. 그래서 변수를 한 번 추출했습니다.
베로 의견) 통일성이 조금 깨지는 것 같습니다.
|
||
private boolean isMemberSamePartExist(final VotingSongPart votingSongPart) { | ||
return votingSongPartRepository.existsByVotingSongAndMemberAndStartSecondAndLength( | ||
votingSongPart.getVotingSong(), |
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.
파라미터로 VotingSong을 받아오는 것이 나을 것 같아요. -> VotingSongPart의 getVotingSong NONE으로 설정합시다!
@@ -48,7 +48,6 @@ public class VotingSongPart { | |||
|
|||
@ManyToOne(fetch = FetchType.LAZY) | |||
@JoinColumn(name = "voting_song_id", foreignKey = @ForeignKey(name = "none"), updatable = false, nullable = false) | |||
@Getter(AccessLevel.NONE) | |||
private VotingSong votingSong; |
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.
간단한 리뷰 남겨봤씁니다!
시간 되실 때 반영해주세요 :) 크지 않은 변경 사항이라 Approve 하겠습니다!
.contentType(ContentType.JSON) | ||
.body(request) | ||
.header("Authorization", "Bearer " + accessToken) | ||
.when().log().all().post("/voting-songs/" + votingSong.getId() + "/parts") |
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.
post("/voting-songs/{songId}/parts", votingSong.getId())
로 적어도 동일하게 작동했던 것 같아요!
} | ||
|
||
private void voteToExistPart(final VotingSong votingSong, final VotingSongPart votingSongPart) { | ||
private boolean isMemberSameVoteExist(final Member member, final VotingSongPart votingSongPart) { |
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.
existSameVoteByMember
라는 메서드 이름은 어떤가요?
@@ -27,8 +29,15 @@ public interface VotingSongPartApi { | |||
description = "파트 수집 중인 노래의 id", | |||
required = true | |||
) | |||
@Parameter( |
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.
굿굿 👍👍👍👍👍
final boolean isVoteExist = voteRepository.existsByMemberAndVotingSongPart(member, votingSongPart); | ||
|
||
//then | ||
Assertions.assertThat(isVoteExist).isTrue(); |
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.
assertthat static import 해주세요!!
RestAssured.given().log().all() | ||
.contentType(ContentType.JSON) | ||
.body(request) | ||
.header("Authorization", "Bearer " + accessToken) |
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.
HttpHeaders.AUTHORIZATION
를 사용해보는 건 어떨까요?
RestAssured.given().log().all() | ||
.contentType(ContentType.JSON) | ||
.body(request) | ||
.header("Authorization", "Bearer " + accessToken) |
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.
ditto
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.
베로가 다 리뷰를 남겨주기도 했고 의도한 로직대로 돌아가는 것 같아서 approve 합니다~
@Autowired | ||
private VotingSongPartRepository votingSongPartRepository; | ||
|
||
@Autowired | ||
private VotingSongRepository votingSongRepository; | ||
private static VotingSong SAVED_SONG; |
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.
이거 위의 필드랑 한 줄만 뛰고, static을 일반 필드보다 위로 올리면 더 깔끔할 것 같습니다 ㅎㅎ
📝작업 내용
VotingSong -> VotingSongParts -> Member 로의 많은 N+1 쿼리가 예상되기에
해당 메서드를 사용해서 확인했습니다.😊
💬리뷰 참고사항
추후에 해당 쿼리에 대한 분석과 인덱스 적용 여부에 대해서 파악해야 됩니다!!😁
멤버가 같은 파트를 등록했을 때는 200(OK), 아닌 경우에는 201(CREATED) 를 사용해서 클라이언트에게 전달하려 했으나 이 부분에 대해서 추후 프론트 팀원들과의 논의가 필요할 것 같습니다!!🫡
#️⃣연관된 이슈
close #461