[FIX] 노벨 통계 조회 시 통계 테이블 데이터 사용 - #631
Merged
Merged
Conversation
ljy1348
force-pushed
the
fix/#630
branch
4 times, most recently
from
September 11, 2026 15:54
78d7bfb to
c232b1d
Compare
GiJungPark
reviewed
Sep 13, 2026
|
|
||
| List<UserNovel> findUserNovelByUser(User user); | ||
|
|
||
| @Query("SELECT un FROM UserNovel un WHERE un.user.userId = :userId") |
Contributor
Author
There was a problem hiding this comment.
반영했습니다. findUserNovelByUserId를 UserNovelCustomRepository/Impl의 QueryDSL 조회로 옮겼고, 탈퇴 처리 중 작품 접근 시 N+1이 발생하지 않도록 novel fetch join을 적용했습니다. (1176dbe)
| @Repository | ||
| public interface NovelRepository extends JpaRepository<Novel, Long>, NovelCustomRepository { | ||
|
|
||
| @Query("SELECT n FROM Novel n LEFT JOIN FETCH n.novelStatistics WHERE n.novelId = :novelId") |
Contributor
Author
There was a problem hiding this comment.
반영했습니다. findByIdWithStatistics를 NovelCustomRepository/Impl의 QueryDSL 조회로 옮기고 novelStatistics left fetch join을 유지했습니다. (49d89dd)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
fix/#630→devKey Changes
1. 노벨 상세 조회에 통계 데이터 적용
GET /novels/{novelId}의 평균 평점과 평가 수를user_novel에서 매번 집계하지 않고novel_statistics.average_rating,rating_count로 조회합니다.2. 서재 조회에 노벨 통계 데이터 적용
GET /users/{userId}/novels,GET /users/{userId}/novels/v2의novelRating을novel_statistics.average_rating기준으로 변경했습니다.userNovelRating은 서재 소유자가 직접 남긴 평점인user_novel.user_novel_rating을 그대로 유지합니다. 두 평점은 서로 다른 필드와 데이터 소스를 사용합니다.SUM/COUNT쿼리와 통계 N+1 조회를 제거했습니다.3. 탈퇴 시 노벨 통계 기여분 차감
User엔티티 대신userId만 전달하며, QueryDSL의findUserNovelByUserId로 차감 대상 서재와 노벨을 fetch join해 조회합니다.Verification
./gradlew apiDocs통과 및 OpenAPI 문서 생성 확인4.3과 사용자 자체 평점3.0이 분리되어 반환되는 것을 확인novel_statistics조인 및 기존 평점SUM/COUNT재집계 쿼리 미발생 확인To Reviewers
user_novel집계와 읽기 전용으로 대조한 결과, 기존 통계 행 누락과 통계값 불일치가 일부 확인됐습니다. 데이터는 직접 수정하지 않았습니다.dev기준으로 이번 변경과 무관한 피드 필터 테스트 3개와 RecentSearch 테스트 1개가 실패하며, 이번 작업 관련 테스트는 모두 통과했습니다.References