WISH-391 - Image Instance Manager 에서의 N+1 query 문제 해결 #236
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.
주요 변경 사항
앱 모듈 수정 (src/app.module.ts)
subscribers옵션에 있던ImageQuerySubscriber를 주석 처리하였습니다.댓글 서비스 개선 (src/features/comment/comment.service.ts)
findOne메서드를 사용하여 단일 엔티티를 조회하던 부분을QueryBuilder기반의 접근 방식으로 전환하였습니다.author) 및 댓글(comment) 데이터를 조회할 때,imageInstanceManager.mapImage를 호출하여 관련 이미지 정보를 함께 매핑하도록 변경하였습니다.이미지 인스턴스 매니저 강화 (src/features/image/image-instance-manager.ts)
mapImage메서드에 상세한 주석과 함께 JSDoc을 추가하여, 해당 메서드가 엔티티의 메타데이터를 기반으로 적절한 join 조건을 생성하는 방식과 동작 방식을 명확하게 문서화하였습니다.User,Funding,Gift) 매핑에 필요한 ID 필드와 이미지 타입을 자동으로 판단하여 join을 처리합니다.mapImages메서드는 다수의 이미지 매핑 상황에 유연하게 대응할 수 있도록 설계되었습니다.쿼리 카운팅 테스트 추가 (src/features/image/image-query.spec.ts)
이미지 쿼리 서브스크라이버 도입 (src/tests/query-subscriber.ts)
Image엔티티에 대한 모든 SQL 쿼리 실행 횟수를 모니터링하는ImageQuerySubscriber를 추가하였습니다.기대 효과
이번 PR은 전반적으로 데이터 조회 로직과 이미지 매핑 방식의 일관성 및 성능 개선을 목표로 진행되었습니다. 향후 테스트 환경과 프로덕션 환경 간의 분리를 통해, 더 안정적이고 유지보수하기 쉬운 시스템으로 발전시킬 수 있을 것으로 기대합니다.
감사합니다.