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

[BE] 체크리스트 방 비교 기능을 구현한다. #979

Merged
merged 18 commits into from
Nov 24, 2024

Conversation

shin-jisong
Copy link
Contributor

❗ Issue

✨ 구현한 기능

체크리스트 방 비교 기능 구현

📢 논의하고 싶은 내용

🎸 기타

Copy link
Contributor

@JINU-CHANG JINU-CHANG left a comment

Choose a reason for hiding this comment

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

시소 코드양만 보아도 고생이 정말 많으셨을 것 같아요 🥹 수고하셨습니다~~~~

@@ -74,6 +77,12 @@ public ResponseEntity<ChecklistsPreviewResponseV1> readLikedChecklistsPreviewV1(
return ResponseEntity.ok(checklistManageService.readLikedChecklistsPreviewV1(user));
}

@GetMapping("/v1/checklists/compare")
Copy link
Contributor

@JINU-CHANG JINU-CHANG Nov 20, 2024

Choose a reason for hiding this comment

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

REST API에서는 자원 중심으로 설계하기 때문에 행위는 HTTP 메서드로 나타내고 URI는 명사구를 사용한다고 알고 있는데, 다른 방식으로 표현해보는 건 어떤가요 ???🤔

Comment on lines +98 to +101
int allAnsweredQuestionCount = checklistQuestionRepository.countAnsweredQuestionsByChecklistIdAndCategoryId(
checklistId, categoryId);
int goodAnsweredQuestionCount = checklistQuestionRepository.countAnsweredQuestionsByChecklistIdAndCategoryIdAndAnswer(
checklistId, categoryId, Answer.GOOD);
Copy link
Contributor

Choose a reason for hiding this comment

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

AnsweredQuestions을 먼저 가져오고 Answer.GOOD인 것만 필터링해서 갯수를 확인하면 2번 데이터베이스에 요청을 보내지 않아도 될 것 같아요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

리팩토링 PR로 반영하겠습니다!!

Comment on lines +106 to +109

double score = ((double) goodAnsweredQuestionCount / allAnsweredQuestionCount) * 100;
return (int) Math.round(score);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

비교를 위한 계산 로직이 꽤 중요한 도메인이라고 생각하는데 도메인 내부에서 처리하는 건 어떤가요? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

리팩토링 PR로 반영하겠습니다!!

Comment on lines +230 to +239
@DisplayName("카테고리 점수 계산 성공 : 답변이 없는 경우")
@Test
void calculateCategoryScore_noAnswers() {
// given & when
Integer categoryId = QuestionFixture.QUESTION1_CATEGORY1.getCategory().getId();
Integer score = checklistQuestionService.calculateCategoryScore(checklist.getId(), categoryId);

// then
assertThat(score).isEqualTo(0);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

계산 로직을 가진 도메인이 있다면 해당 테스트도 도메인 테스트로 변경할 수 있을 것 같아요~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

리팩토링 PR로 반영하겠습니다!!

@shin-jisong shin-jisong merged commit d8937cb into dev Nov 24, 2024
1 check passed
@shin-jisong shin-jisong deleted the feat/974-checklist-compare branch November 24, 2024 07:58
@shin-jisong shin-jisong restored the feat/974-checklist-compare branch November 24, 2024 07:59
@shin-jisong shin-jisong deleted the feat/974-checklist-compare branch November 24, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants