Conversation
Summary of ChangesHello @ParkJiYeoung8297, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 캠페인 태그를 다양한 정렬 기준에 따라 조회할 수 있는 새로운 API를 구현합니다. 이를 통해 사용자는 캠페인 콘텐츠에 필요한 태그를 보다 체계적으로 탐색하고 활용할 수 있게 됩니다. 새로운 서비스 레이어, 컨트롤러, 그리고 데이터 전송 객체(DTO)들이 추가되어 기능이 완성되었으며, 관련 Swagger 문서도 업데이트되었습니다. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이번 PR은 캠페인 태그를 정렬 기준에 따라 조회하는 API를 추가하는 것을 목표로 하고 있습니다. 전반적으로 기능 구현은 잘 되었으나, 성능 및 유지보수성 측면에서 개선할 점이 보입니다. ContentTagSort와 ContentTagType enum 간의 연관 관계를 타입-세이프하게 개선하고, TagContentSortQueryService에서 대규모 컬렉션의 인메모리 필터링 대신 데이터베이스 계층으로 로직을 푸시하여 성능을 최적화하는 것을 제안합니다.
| List<TagContent> allTags = tagContentRepository.findAll(); | ||
|
|
||
| return Arrays.stream(ContentTagSort.values()) | ||
| .map(sort -> { | ||
| List<TagContent> filtered = allTags.stream() | ||
| .filter(tag -> | ||
| tag.getTagType().name().equals(sort.name()) | ||
| ) | ||
| .toList(); | ||
|
|
||
| return TagContentSortResponse.from(sort, filtered); | ||
| }) | ||
| .toList(); |
There was a problem hiding this comment.
현재 tagContentRepository.findAll()을 호출하여 모든 태그를 메모리로 가져온 후, ContentTagType별로 그룹화하고 있습니다. 태그의 수가 많아질 경우, 대규모 컬렉션을 메모리에서 필터링하고 그룹화하는 것은 심각한 성능 저하를 유발할 수 있습니다. findAll() 대신, ContentTagType별로 미리 그룹화된 태그를 반환하는 전용 쿼리 메서드를 TagContentRepository에 추가하여 데이터베이스 계층에서 이 로직을 처리하는 것을 강력히 권장합니다. 이렇게 하면 메모리 사용량을 줄이고 데이터베이스의 효율적인 인덱싱을 활용하여 성능을 크게 향상시킬 수 있습니다.
References
- Avoid filtering large collections in memory; instead, push filtering logic down to the database layer by adding specific query methods to the repository for better performance.
There was a problem hiding this comment.
나중에 수정해볼게 태그 25개라 일단은 그냥 함
| public enum ContentTagSort { | ||
| FORMAT("형식"), | ||
| CATEGORY("종류"), | ||
| TONE("톤"), | ||
| INVOLVEMENT("관여도"), | ||
| USAGE_RANGE("활용 범위"); | ||
|
|
||
| private final String korName; | ||
| } |
There was a problem hiding this comment.
현재 ContentTagSort와 ContentTagType enum은 이름(문자열)을 기준으로 연결되어 있어, 향후 유지보수 시 오류가 발생할 가능성이 있습니다. 예를 들어, 한쪽 enum의 이름만 변경될 경우 연관 로직이 오동작하게 됩니다.
ContentTagSort에 ContentTagType을 직접 필드로 추가하여 타입-세이프(type-safe)하게 연관 관계를 맺는 것을 권장합니다. 이렇게 하면 코드의 안정성과 가독성이 향상됩니다.
참고: 아래 제안을 적용하려면 파일 상단에 import com.example.RealMatch.tag.domain.enums.ContentTagType; 구문을 추가해야 합니다.
| public enum ContentTagSort { | |
| FORMAT("형식"), | |
| CATEGORY("종류"), | |
| TONE("톤"), | |
| INVOLVEMENT("관여도"), | |
| USAGE_RANGE("활용 범위"); | |
| private final String korName; | |
| } | |
| public enum ContentTagSort { | |
| FORMAT("형식", ContentTagType.FORMAT), | |
| CATEGORY("종류", ContentTagType.CATEGORY), | |
| TONE("톤", ContentTagType.TONE), | |
| INVOLVEMENT("관여도", ContentTagType.INVOLVEMENT), | |
| USAGE_RANGE("활용 범위", ContentTagType.USAGE_RANGE); | |
| private final String korName; | |
| private final ContentTagType tagType; | |
| } |
feat(#362): 캠페인 태그 조회 api 추가
Summary
캠페인 태그 조회 api 추가
Changes
Type of Change
Related Issues
참고 사항