-
Notifications
You must be signed in to change notification settings - Fork 6
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
[BE] 방 비교 결과 조회 API에 기능을 추가 구현한다. #215
Conversation
...good/src/main/java/com/bang_ggood/checklist/dto/response/ChecklistWithScoreReadResponse.java
Outdated
Show resolved
Hide resolved
...good/src/main/java/com/bang_ggood/checklist/dto/response/ChecklistWithScoreReadResponse.java
Show resolved
Hide resolved
backend/bang-ggood/src/main/java/com/bang_ggood/checklist/repository/ChecklistRepository.java
Outdated
Show resolved
Hide resolved
backend/bang-ggood/src/main/java/com/bang_ggood/checklist/service/ChecklistService.java
Outdated
Show resolved
Hide resolved
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.
수고많으셨습니다 👏👏👏
궁금한부분 몇개 코멘트 남겨두었어요~
backend/bang-ggood/src/test/java/com/bang_ggood/checklist/service/ChecklistServiceTest.java
Outdated
Show resolved
Hide resolved
List<Integer> ranks = ChecklistRank.calculateRanksByDescendingScores(scores); | ||
|
||
for (int idx = 0; idx < checklistsWithScore.size(); idx++) { | ||
ChecklistWithScoreReadResponse checklistWithScore = checklistsWithScore.get(idx); | ||
checklistWithScore.assignRank(ranks.get(idx)); | ||
} |
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.
.sorted(Comparator.comparing(ChecklistWithScoreReadResponse::getScore).reversed())
이미 정렬이 되어 있으니 이 순서로 for문 돌면서 rank 부여하면 될 것 같은데 ChecklistRank.calculateRanksByDescendingScores(scores)의 역할을 잘 모르겠어요 🥲
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.
간단하게 리뷰 남겼습니다! 수고하셨어요~
@@ -19,6 +19,9 @@ public enum Grade { | |||
} | |||
|
|||
public static Grade from(String grade) { | |||
if(grade == 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.
공백이 제대로 들어가지 않은 것 같아요
정책상 수정될 코드 같기는 하네요~
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.
정책에 맞게 수정해놨습니다!
List<CategoryScoreReadResponse> categories | ||
) { | ||
public static ChecklistWithScoreReadResponse of(Checklist checklist, int checklistOptionCount, int checklistScore, | ||
public class ChecklistWithScoreReadResponse { |
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.
record에서 class로 바꾼 이유가 있으신가요?
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.
객체 생성시 rank를 할당할 수가 없는데 Record를 사용할 경우 setter 사용이 불가했습니다.
rank 계산 후 값을 할당해주기 위해 class로 변경하였습니다!
@@ -25,7 +25,17 @@ default Checklist getById(long id) { | |||
|
|||
List<Checklist> findByUser(User user); | |||
|
|||
List<Checklist> findByUserAndIdIn(User user, List<Long> checklistIds); | |||
@Query("SELECT c FROM Checklist c " |
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.
작성 완료!
@@ -173,13 +174,13 @@ public SelectedChecklistResponse readChecklistById(long id) { | |||
|
|||
List<SelectedOptionResponse> options = readOptionsByChecklistId(id); | |||
|
|||
List<SelectedCategoryQuestionsResponse> selectedCategoryQuestionsRespons = | |||
List<SelectedCategoryQuestionsResponse> selectedCategoryQuestionsResponse = | |||
readCategoryQuestionsByChecklistId(id); | |||
|
|||
int checklistScore = ChecklistScore.calculateTotalScore(checklist.getQuestions()); |
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.
ChecklistScore를 호출하기 위해 체크리스트의 질문들을 꺼내서 넣는 게 어색하게 느껴져요!
checklist 내부에서 checklistScore를 갖고 있고 결과값을 넘기는 함수를 구현하는 게 어떨까요?
고려만 해 주세요 ㅎㅎ
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.
해당 부분을 고민해봤는데 저희가 oneToMany를 제거하면 해당로직도 작동하지 않게 되어서,
아예 checklistQuestionRepository에서 질문들을 조회하는 방식으로 구현해야할 것 같습니다!
다만 방 체크리스트 조회 해당 pr이 열려있어서 여기에서 반영하도록 하겠습니다!
@@ -6,6 +6,7 @@ public enum ExceptionCode { | |||
|
|||
// 전체 | |||
INVALID_PARAMETER(HttpStatus.BAD_REQUEST, "잘못된 인자입니다."), | |||
SCORE_NOT_DESCENDING_SORTED(HttpStatus.BAD_REQUEST, "정렬되지 않은 점수입니다."), |
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.
Score 분류를 따로 만들어서 분류했습니다!
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class ChecklistRankTest { |
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.
꼼꼼하게 테스트해 주셨네요 👍
…97-checklist-comparison-improvement # Conflicts: # backend/bang-ggood/src/main/java/com/bang_ggood/checklist/repository/ChecklistOptionRepository.java # backend/bang-ggood/src/main/java/com/bang_ggood/checklist/service/ChecklistService.java # backend/bang-ggood/src/test/java/com/bang_ggood/checklist/service/ChecklistServiceTest.java # backend/bang-ggood/src/test/java/com/bang_ggood/user/UserFixture.java
❗ Issue
✨ 구현한 기능
📢 논의하고 싶은 내용
미 선택 질문에 대한 답변을 전체 점수 계산에 반영할 지에 대한 여부
🎸 기타