diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/RoadMapService.java b/backend/src/main/java/wooteco/prolog/roadmap/application/RoadMapService.java index 450d6be28..fbfae1d22 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/RoadMapService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/RoadMapService.java @@ -6,7 +6,7 @@ import wooteco.prolog.roadmap.application.dto.KeywordsResponse; import wooteco.prolog.roadmap.domain.Keyword; import wooteco.prolog.roadmap.domain.repository.KeywordRepository; -import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndDoneQuizCount; +import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndAnsweredQuizCount; import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndTotalQuizCount; import java.util.List; @@ -24,10 +24,10 @@ public class RoadMapService { public KeywordsResponse findAllKeywordsWithProgress(final Long curriculumId, final Long memberId) { final List keywords = keywordRepository.findAllByCurriculumId(curriculumId); final Map totalQuizCounts = getTotalQuizCounts(); - final Map doneQuizCounts = getDoneQuizCounts(memberId); + final Map answeredQuizCounts = getAnsweredQuizCounts(memberId); final KeywordsResponse keywordsResponse = KeywordsResponse.of(keywords); - keywordsResponse.setProgress(totalQuizCounts, doneQuizCounts); + keywordsResponse.setProgress(totalQuizCounts, answeredQuizCounts); return keywordsResponse; } @@ -40,11 +40,11 @@ private Map getTotalQuizCounts() { KeywordIdAndTotalQuizCount::getTotalQuizCount)); } - private Map getDoneQuizCounts(final Long memberId) { - return keywordRepository.findDoneQuizCountByMemberId(memberId).stream() + private Map getAnsweredQuizCounts(final Long memberId) { + return keywordRepository.findAnsweredQuizCountByMemberId(memberId).stream() .collect( toMap( - KeywordIdAndDoneQuizCount::getKeywordId, - KeywordIdAndDoneQuizCount::getDoneQuizCount)); + KeywordIdAndAnsweredQuizCount::getKeywordId, + KeywordIdAndAnsweredQuizCount::getAnsweredQuizCount)); } } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordResponse.java b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordResponse.java index adb464f8e..0255414ec 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordResponse.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordResponse.java @@ -81,10 +81,10 @@ private static List createChildren(final Set children) .collect(Collectors.toList()); } - public void setProgress(final Map totalQuizCounts, final Map doneQuizCounts) { + public void setProgress(final Map totalQuizCounts, final Map answeredQuizCounts) { totalQuizCount = totalQuizCounts.getOrDefault(keywordId, 0); - doneQuizCount = doneQuizCounts.getOrDefault(keywordId, 0); + doneQuizCount = answeredQuizCounts.getOrDefault(keywordId, 0); - childrenKeywords.forEach(child -> child.setProgress(totalQuizCounts, doneQuizCounts)); + childrenKeywords.forEach(child -> child.setProgress(totalQuizCounts, answeredQuizCounts)); } } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordsResponse.java b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordsResponse.java index 360e1e574..46e8952ed 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordsResponse.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordsResponse.java @@ -28,7 +28,7 @@ public static KeywordsResponse of(final List keywords) { return new KeywordsResponse(keywordsResponse); } - public void setProgress(final Map totalQuizCounts, final Map doneQuizCounts) { - data.forEach(response -> response.setProgress(totalQuizCounts, doneQuizCounts)); + public void setProgress(final Map totalQuizCounts, final Map answeredQuizCounts) { + data.forEach(response -> response.setProgress(totalQuizCounts, answeredQuizCounts)); } } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/KeywordRepository.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/KeywordRepository.java index 99806ca93..c9f96348b 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/KeywordRepository.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/KeywordRepository.java @@ -4,7 +4,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import wooteco.prolog.roadmap.domain.Keyword; -import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndDoneQuizCount; +import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndAnsweredQuizCount; import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndTotalQuizCount; import java.util.List; @@ -17,13 +17,13 @@ public interface KeywordRepository extends JpaRepository { "GROUP BY k.id") List findTotalQuizCount(); - @Query("SELECT k.id AS keywordId, COUNT (e.id) AS doneQuizCount " + + @Query("SELECT k.id AS keywordId, COUNT (e.id) AS answeredQuizCount " + "FROM Keyword k " + "JOIN Quiz q ON k.id = q.keyword.id " + "JOIN EssayAnswer e ON e.quiz.id = q.id " + "WHERE e.member.id = :memberId " + "GROUP BY k.id ") - List findDoneQuizCountByMemberId(@Param("memberId") Long memberId); + List findAnsweredQuizCountByMemberId(@Param("memberId") Long memberId); Keyword findFetchByIdOrderBySeq(@Param("keywordId") Long keywordId); diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/dto/KeywordIdAndDoneQuizCount.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/dto/KeywordIdAndAnsweredQuizCount.java similarity index 50% rename from backend/src/main/java/wooteco/prolog/roadmap/domain/repository/dto/KeywordIdAndDoneQuizCount.java rename to backend/src/main/java/wooteco/prolog/roadmap/domain/repository/dto/KeywordIdAndAnsweredQuizCount.java index d25aef114..63009ab0e 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/dto/KeywordIdAndDoneQuizCount.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/dto/KeywordIdAndAnsweredQuizCount.java @@ -1,7 +1,7 @@ package wooteco.prolog.roadmap.domain.repository.dto; -public interface KeywordIdAndDoneQuizCount { +public interface KeywordIdAndAnsweredQuizCount { long getKeywordId(); - int getDoneQuizCount(); + int getAnsweredQuizCount(); } diff --git a/backend/src/test/java/wooteco/prolog/roadmap/application/RoadMapServiceTest.java b/backend/src/test/java/wooteco/prolog/roadmap/application/RoadMapServiceTest.java index 287ac7226..85c05b86a 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/RoadMapServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/RoadMapServiceTest.java @@ -86,17 +86,17 @@ void findAllKeywordsWithProgress() { roots.hasSize(2) .satisfies(containsKeywordIds(root1.getId(), root2.getId())) .satisfies(containsTotalQuizCounts(0, 1)) - .satisfies(containsDoneQuizCounts(0, 0)); + .satisfies(containsAnsweredQuizCounts(0, 0)); oneDepthChildren.hasSize(1) .satisfies(containsKeywordIds(oneDepthChild.getId())) .satisfies(containsTotalQuizCounts(1)) - .satisfies(containsDoneQuizCounts(0)); + .satisfies(containsAnsweredQuizCounts(0)); twoDepthChildren.hasSize(1) .satisfies(containsKeywordIds(twoDepthChild.getId())) .satisfies(containsTotalQuizCounts(0)) - .satisfies(containsDoneQuizCounts(0)); + .satisfies(containsAnsweredQuizCounts(0)); }); } @@ -137,21 +137,21 @@ void findAllKeywordsWithProgress_login() { roots.hasSize(2) .satisfies(containsKeywordIds(root1.getId(), root2.getId())) .satisfies(containsTotalQuizCounts(0, 1)) - .satisfies(containsDoneQuizCounts(0, 1)); + .satisfies(containsAnsweredQuizCounts(0, 1)); oneDepthChildren.hasSize(1) .satisfies(containsKeywordIds(oneDepthChild.getId())) .satisfies(containsTotalQuizCounts(1)) - .satisfies(containsDoneQuizCounts(0)); + .satisfies(containsAnsweredQuizCounts(0)); twoDepthChildren.hasSize(1) .satisfies(containsKeywordIds(twoDepthChild.getId())) .satisfies(containsTotalQuizCounts(1)) - .satisfies(containsDoneQuizCounts(1)); + .satisfies(containsAnsweredQuizCounts(1)); }); } - private Consumer> containsDoneQuizCounts(final Integer... expected) { + private Consumer> containsAnsweredQuizCounts(final Integer... expected) { return keywords -> assertThat(keywords) .map(KeywordResponse::getDoneQuizCount) .containsExactlyInAnyOrder(expected); diff --git a/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java b/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java index 133c685a6..4f018ebce 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java @@ -14,7 +14,7 @@ import wooteco.prolog.roadmap.domain.repository.EssayAnswerRepository; import wooteco.prolog.roadmap.domain.repository.KeywordRepository; import wooteco.prolog.roadmap.domain.repository.QuizRepository; -import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndDoneQuizCount; +import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndAnsweredQuizCount; import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndTotalQuizCount; import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.repository.SessionRepository; @@ -121,7 +121,7 @@ class KeywordRepositoryTest { sessionId); // then - assertThat(extractParentKeyword.size()).isEqualTo(1); + assertThat(extractParentKeyword).hasSize(1); } @Test @@ -219,15 +219,15 @@ void findDoneQuizCountByMemberId() { essayAnswerRepository.save(new EssayAnswer(quiz2, "쓰라고 해서요ㅠ", member)); //when - final List doneQuizCounts = keywordRepository.findDoneQuizCountByMemberId(member.getId()); + final List doneQuizCounts = keywordRepository.findAnsweredQuizCountByMemberId(member.getId()); //then assertSoftly(softAssertions -> { softAssertions.assertThat(doneQuizCounts) - .map(KeywordIdAndDoneQuizCount::getKeywordId) + .map(KeywordIdAndAnsweredQuizCount::getKeywordId) .containsExactly(parent.getId()); softAssertions.assertThat(doneQuizCounts) - .map(KeywordIdAndDoneQuizCount::getDoneQuizCount) + .map(KeywordIdAndAnsweredQuizCount::getAnsweredQuizCount) .containsExactly(2); }); }