Skip to content

Commit

Permalink
[BE] 코스 전체 조회시 불필요하게 실행되는 쿼리 제거
Browse files Browse the repository at this point in the history
course_stack 조회 쿼리 한 번에 실행되도록 수정

 select
        c1_0.course_id,
        c1_0.course_stack_id,
        c1_0.created_at,
        c1_0.modified_at,
        c1_0.stack_id
    from
        course_stack c1_0
    where
        c1_0.course_id in (39,34,37,32,35,30,36,31,33,27,29,28,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
  • Loading branch information
Jinwook94 committed Nov 7, 2023
1 parent f53c6b9 commit c6fe53a
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -89,10 +89,8 @@ private CourseDetailResponse createCourseDetailResponse(Course course, boolean i
}

@Transactional(readOnly = true)
public Page<CourseResponse> findAll(Long memberId, int page, int size, String sort,
MultiValueMap<String, String> params) {
public Page<CourseResponse> findAll(Long memberId, int page, int size, String sort, MultiValueMap<String, String> params) {
boolean isLogin = authService.validateLogin(memberId);

Predicate combinedPredicate = getCombinedPredicate(params);

return getCoursePage(page, size, sort, combinedPredicate)
Expand All @@ -101,7 +99,9 @@ public Page<CourseResponse> findAll(Long memberId, int page, int size, String so

private CourseResponse createCourseResponse(Course course, boolean isLogin, Long memberId) {
boolean isBookmarked = isLogin && courseBookmarkRepository.existsByBookmark_Member_IdAndCourse_Id(memberId, course.getId());
List<Stack> stacks = courseStackRepository.findStacksByCourseId(course.getId());
List<Stack> stacks = course.getCourseStacks().stream()
.map(CourseStack::getStack)
.toList();
return CourseResponse.of(course, stacks, isBookmarked);
}

Expand Down

0 comments on commit c6fe53a

Please sign in to comment.