-
Notifications
You must be signed in to change notification settings - Fork 3
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: 토너먼트 복식 부전승 로직 구현 #526
feat: 토너먼트 복식 부전승 로직 구현 #526
Conversation
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.
확인해주세요!
@@ -64,7 +65,8 @@ public boolean allMatchesFinishedForLeague(Long leagueId) { | |||
|
|||
@Override | |||
public boolean allMatchesNotStartedForLeague(Long leagueId) { | |||
return doublesMatchRepository.allMatchesNotStartedForLeague(leagueId); | |||
List<MatchStatus> statuses = Arrays.asList(MatchStatus.NOT_STARTED, MatchStatus.BYE); |
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.
이 두가지 Status가 어떤 상태인지 변수명에 더 드러나면 좋을 것 같아요.
@@ -69,6 +79,10 @@ public BracketInfo makeBracket(League league, List<LeagueParticipant> leaguePart | |||
allMatches.addAll(createFirstRoundMatches(league, currentParticipants)); | |||
allMatches.addAll(createSubsequentRoundsMatches(league, totalRounds)); | |||
|
|||
allMatches.stream() | |||
.filter(doublesMatch -> doublesMatch.getMatchStatus() == MatchStatus.BYE && doublesMatch.getTeam1() != null) |
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.
doublesMatch.getTeam1()이 null이 아니어야 하는 조건을 체크하는 이유가 무엇일까요?
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.
만약 doublesMatch.getTeam1()이 null이라면, 다음 라운드로 승자를 전달할 수 없어 정상적인 대진표 업데이트가 불가능합니다. 이를 사전에 방지하기 위해 조건을 확인합니다
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.
Team Entity에 getEmptyTeam() 등을 추가해서 null이 직접적으로 return 되지 않도록 하면 더 좋을 것 같습니다! 지금은 null이 담고 있는 의미가 없어서 무슨 목적인지 명확하지 않은 것 같아요. 추후 리팩토링 시 고려해주세요!
@@ -82,6 +96,10 @@ public SetInfo.Main registerSetScoreInMatch(Long matchId, Integer setNumber, | |||
|
|||
validatePreviousRoundCompletion(doublesMatch.getLeague().getLeagueId(), doublesMatch.getRoundNumber()); | |||
|
|||
if (doublesMatch.getMatchStatus() == MatchStatus.BYE) { | |||
throw new ByeMatchException(doublesMatch.getId()); |
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.
RegisterScoreInByeMatchException 어떨까요? 부전승이면 무조건 예외가 발생하는 것인가? 라는 생각이 들었어요
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.
또 match type도 넘겨주면 좋을 것 같습니다! SINGLES/DOUBLES 인지도 넘어가야 할 것 같아요
if (isParticipantOddSize(participants)) { | ||
Team byeTeam = new Team(participants.remove(participants.size() - 1), | ||
participants.get(participants.size() - 2)); | ||
DoublesMatch byeMatch = new DoublesMatch(league, byeTeam, null, 1); |
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.
null을 여기 전달하는 이유가 있을까요?
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.
부전승 매치의 participant2 는 Null 이어야 합니다
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.
LeagueParticipant (entity) 내부에 아래와 같이 부전승을 위한 비어 있는 참여자를 return 하는 정적 팩토리 메서드를 추가하면 더 좋을 것 같습니다! 지금으로서는 "부전승 매치의 participant2 는 Null 이어야 합니다"라는 맥락을 알기가 어려운데, 아래와 같이 변경될 수 있을 것 같아요.
본문의 코드
DoublesMatch match = new DoublesMatch(league, byeTeam, LeagueParticipant.emptyParticipantForByeMatch(), roundNumber);
LeagueParticipant.java (엔티티 코드)
public static LeagueParticipant emptyParticipantForByeMatch() {
return null;
}
if (isParticipantOddSize(participants)) { | ||
Team byeTeam = new Team(participants.remove(participants.size() - 1), | ||
participants.get(participants.size() - 2)); |
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.
participants.size에서 1을 빼는 이유와 2를 빼는 이유가 와닿지 않아요. 상수로 빼는게 어떨까요?
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.
remove를 하는 목적은 뭘까요?
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.
remove 뜻은 participant 에서 해당 인덱스의 값을 제거 후 get 하는 것입니다. get을 쓰지 않고 remove 를 쓰는 이유는
remove를 사용하면 "해당 참가자는 이후 로직에서 필요 없으므로 제거한다"는 의도를 명확히 전달할 수 있습니다. 이는 코드의 가독성과 유지보수성을 높일수 있습니다.
if (match.getMatchStatus() == MatchStatus.BYE) { | ||
return match.getTeam1(); | ||
} | ||
if (match.getTeam1MatchResult() == MatchResult.WIN) { | ||
return match.getTeam1(); | ||
} |
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.
요거
if(match.getMatchStatus() == MatchStatus.BYE || match.getMatchStatus() == MatchResult.WIN) {
return match.getTeam1();
}
로 갈 수도 있지 않아요?
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.
수정사항 확인했습니다! 수고하셨습니다~!
@@ -104,7 +104,7 @@ public enum ErrorCode { | |||
CLUB_OWNER_CANT_WITHDRAW(412, "동호회원이 2명 이상인 동호회 회장은 동호회를 탈퇴할 수 없습니다."), | |||
NOT_LEAGUE_OWNER(412, "경기를 만든 사용자만 수정 및 삭제를 할 수 있습니다"), | |||
CLUB_MEMBER_EXPEL_EXCEPTION(412, "해당 동호회에서 제제를 받아 가입 신청을 할 수 없습니다."), | |||
BYE_MATCH(412, "해당 매치는 부전승 매치 입니다"), | |||
BYE_MATCH_ACTION_NOT_ALLOWED(412, "해당 매치는 부전승 매치이기 때문에 점수를 수정할 수 없습니다"), |
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.
ACTION이 조금 모호한데.. SCORE_UPDATE_NOT_ALLOWED_IN_BYE_MATCH는 어떨까요? 😀
@@ -64,12 +65,13 @@ public boolean allMatchesFinishedForLeague(Long leagueId) { | |||
|
|||
@Override | |||
public boolean allMatchesNotStartedForLeague(Long leagueId) { | |||
return doublesMatchRepository.allMatchesNotStartedForLeague(leagueId); | |||
List<MatchStatus> UnPlayedMatchStatuses = Arrays.asList(MatchStatus.NOT_STARTED, MatchStatus.BYE); | |||
return doublesMatchRepository.allMatchesNotStartedForLeague(leagueId, UnPlayedMatchStatuses); |
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.
리뷰 추가했습니다.
} | ||
|
||
@Override | ||
public boolean allRoundMatchesDone(Long leagueId, int roundNumber) { | ||
List<MatchStatus> statuses = List.of(MatchStatus.FINISHED, MatchStatus.BYE); | ||
return doublesMatchRepository.areAllMatchesFinishedOrBye(leagueId, roundNumber, statuses); | ||
List<MatchStatus> CompletedOrBypassedStatuses = List.of(MatchStatus.FINISHED, MatchStatus.BYE); |
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.
변수명은 소문자로 적어야 합니다 22
@@ -69,6 +79,10 @@ public BracketInfo makeBracket(League league, List<LeagueParticipant> leaguePart | |||
allMatches.addAll(createFirstRoundMatches(league, currentParticipants)); | |||
allMatches.addAll(createSubsequentRoundsMatches(league, totalRounds)); | |||
|
|||
allMatches.stream() | |||
.filter(doublesMatch -> doublesMatch.getMatchStatus() == MatchStatus.BYE && doublesMatch.getTeam1() != null) |
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.
Team Entity에 getEmptyTeam() 등을 추가해서 null이 직접적으로 return 되지 않도록 하면 더 좋을 것 같습니다! 지금은 null이 담고 있는 의미가 없어서 무슨 목적인지 명확하지 않은 것 같아요. 추후 리팩토링 시 고려해주세요!
updateNextRoundMatch(doublesMatch); | ||
boolean allRoundMatchesDone = doublesMatchReader.allRoundMatchesDone(doublesMatch.getLeague().getLeagueId(), | ||
doublesMatch.getRoundNumber()); | ||
boolean currentRoundInTotalRound = |
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.
boolean 타입은 앞에 is 를 붙인 네이밍 컨벤션을 적용해보는게 어떨까요?
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.
복수형일 때는 boolean 값 앞에 is를 안붙이는 거로 알고 있는데 is 를 붙여야 하나요?
@@ -69,6 +80,10 @@ public BracketInfo makeBracket(League league, List<LeagueParticipant> leaguePart | |||
allMatches.addAll(createFirstRoundMatches(league, currentParticipants)); | |||
allMatches.addAll(createSubsequentRoundsMatches(league, totalRounds)); | |||
|
|||
allMatches.stream() | |||
.filter(doublesMatch -> doublesMatch.getMatchStatus() == MatchStatus.BYE && doublesMatch.getTeam1() != null) | |||
.forEach(this::updateNextRoundMatch); |
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.
이거 다음 라운드 매치에 Participant 업데이트하는 메서드일까요? 만약 그렇다면, updateNextRoundMatchParticipant가 어떨까요? 지금은 다음 라운드 매치를 어떻게 업데이트하는 것인지 조금 알기 어려운 것 같아요
PR에 대한 설명 🔍
PR에서 중점적으로 확인되어야 하는 사항