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

feat-be: Dashboard 관련 API 쿼리 최적화 #718

Merged
merged 8 commits into from
Sep 25, 2024

Conversation

Chocochip101
Copy link
Member

@Chocochip101 Chocochip101 commented Sep 25, 2024

  • 대시보드 관련 API의 쿼리를 줄였습니다.

작업 내용

  • 불필요한 clubId -> club -> dashboard 조회 로직을 clubId -> dashboard로 변경했습니다.
  • ApplyForm 마다 Applicant 조회 로직을 fetch join을 통해 한 번에 조회하게 변경했습니다.
  • ApplyForm과 Dashboard를 fetch join을 통해 한 번에 조회하게 변경했습니다.
  • 조회 실행 SQL을 확인할 수 있도록 더미 데이터를 추가했습니다.
  • Dashboard POST요청의 Insert 쿼리도 최적화하고 싶었으나, batch insert를 쓰기 위해서는 id 생성 전략을 identity에서 다른 전략으로 바꿔야한다고 하더라고요. 변경 사항이 많을 것 같아서 수정하지 않았습니다.

참고

관련 이슈

PR 체크리스트

  • 테스트는 모두 통과했나요?
  • 빌드는 성공했나요?
  • 코드 포맷팅을 진행했나요?
  • PR 내부의 예시는 삭제하셨나요?

Copy link
Contributor

1727238446.045859

Copy link
Contributor

1727238448.570719

@Chocochip101 Chocochip101 self-assigned this Sep 25, 2024
Copy link
Contributor

📌 Test Coverage Report

Overall Project 77.3%
Files changed 100% 🍏

File Coverage
DashboardService.java 100% 🍏
DashboardFacade.java 100% 🍏
DashboardApplyFormDto.java 100% 🍏

@Chocochip101 Chocochip101 changed the title feat-be: dashboard 관련 API 쿼리 최적화 feat-be: Dashboard 관련 API 쿼리 최적화 Sep 25, 2024
@Chocochip101
Copy link
Member Author

쿼리에 대한 테스트 추가하겠습니다.

@Chocochip101
Copy link
Member Author

테스트 추가 완료했습니다.

Copy link
Member

@cutehumanS2 cutehumanS2 left a comment

Choose a reason for hiding this comment

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

👍
간단한 코멘트 남겼습니다.
확인 부탁드려요 ~

Comment on lines 87 to 97
// then
assertThat(applicants).hasSize(3);

assertAll(
() -> assertThat(applicants).contains(applicant1),
() -> assertThat(applicants).contains(applicant2),
() -> assertThat(applicants).contains(applicant3)
);
}

}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// then
assertThat(applicants).hasSize(3);
assertAll(
() -> assertThat(applicants).contains(applicant1),
() -> assertThat(applicants).contains(applicant2),
() -> assertThat(applicants).contains(applicant3)
);
}
}
// then
assertThat(applicants).hasSize(3);
assertThat(applicants).containsExactlyInAnyOrder(applicant1, applicant2, applicant3);
}
}

이렇게 해도 괜찮지 않을까요? ?

Copy link
Contributor

@xogns1514 xogns1514 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~~잘 작동하네요!

Comment on lines +16 to +23
@Query("""
SELECT new com.cruru.dashboard.domain.DashboardApplyFormDto(d, a)
FROM ApplyForm a
JOIN FETCH a.dashboard d
JOIN FETCH d.club c
WHERE c.id = :clubId
""")
List<DashboardApplyFormDto> findAllByClub(@Param("clubId") Long clubId);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏿

…ERFORMANCE_01_05

# Conflicts:
#	backend/src/main/java/com/cruru/applicant/domain/repository/ApplicantRepository.java
#	backend/src/main/java/com/cruru/applyform/domain/repository/ApplyFormRepository.java
#	backend/src/test/java/com/cruru/applicant/domain/repository/ApplicantRepositoryTest.java
@Chocochip101 Chocochip101 merged commit f3ae42b into be-705-API_PERFORMANCE_01 Sep 25, 2024
@Chocochip101 Chocochip101 deleted the be-705-API_PERFORMANCE_01_05 branch September 25, 2024 06:23
@Chocochip101 Chocochip101 added feature 새로운 기능 backend 백엔드 labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend 백엔드 feature 새로운 기능
Projects
Status: 완료
Development

Successfully merging this pull request may close these issues.

3 participants