fix: Article 1+4N 문제 해결#2268
Conversation
# Conflicts: # src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java
📝 WalkthroughWalkthroughThis PR introduces a new ChangesArticle Summary Read-Model and Repository
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java (1)
155-157: ⚡ Quick winSkip repository access when there are no target article IDs.
Add an early return before querying summaries to avoid unnecessary DB calls on empty notification batches.
Proposed patch
public void sendKeywordNotification(KeywordNotificationRequest request) { Set<Integer> updateNotificationIds = request.updateNotification(); + if (updateNotificationIds == null || updateNotificationIds.isEmpty()) { + return; + } List<ArticleSummary> articleSummaries = articleRepository.findAllSummariesByIdIn(updateNotificationIds);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java` around lines 155 - 157, The code calls articleRepository.findAllSummariesByIdIn(...) even when the set of IDs is empty; add an early return right after computing Set<Integer> updateNotificationIds = request.updateNotification() that checks if updateNotificationIds is empty and returns (or skips further processing) to avoid the DB call; modify the method containing updateNotificationIds and articleRepository.findAllSummariesByIdIn(...) to short-circuit when updateNotificationIds.isEmpty() before invoking articleRepository.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java`:
- Around line 155-157: The code calls
articleRepository.findAllSummariesByIdIn(...) even when the set of IDs is empty;
add an early return right after computing Set<Integer> updateNotificationIds =
request.updateNotification() that checks if updateNotificationIds is empty and
returns (or skips further processing) to avoid the DB call; modify the method
containing updateNotificationIds and
articleRepository.findAllSummariesByIdIn(...) to short-circuit when
updateNotificationIds.isEmpty() before invoking articleRepository.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 28959010-3ba4-49f7-a37d-b362caa5b972
📒 Files selected for processing (3)
src/main/java/in/koreatech/koin/domain/community/article/model/readmodel/ArticleSummary.javasrc/main/java/in/koreatech/koin/domain/community/article/repository/ArticleRepository.javasrc/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java
🔍 개요
select a1_0.id, a1_0.board_id, a1_0.content, a1_0.created_at, a1_0.hit, a1_0.is_deleted, a1_0.is_notice, a1_0.title, a1_0.updated_at from new_articles a1_0 where ( a1_0.is_deleted = ? ) and a1_0.id in ( ? )select k1_0.id, k1_0.article_id, k1_0.created_at, k1_0.is_deleted, k1_0.updated_at, k1_0.user_id from new_koin_articles k1_0 where k1_0.article_id = ? and ( k1_0.is_deleted = ? )select k1_0.id, k1_0.article_id, k1_0.author, k1_0.created_at, k1_0.is_deleted, k1_0.portal_hit, k1_0.portal_num, k1_0.registered_at, k1_0.updated_at, k1_0.url from new_koreatech_articles k1_0 where k1_0.article_id = ? and ( k1_0.is_deleted = ? )select l1_0.id, l1_0.article_id, l1_0.author_id, l1_0.category, l1_0.created_at, l1_0.found_at, l1_0.found_date, l1_0.found_place, l1_0.is_council, l1_0.is_deleted, l1_0.is_found, l1_0.type, l1_0.updated_at from lost_item_articles l1_0 where l1_0.article_id = ?select k1_0.id, k1_0.admin_id, k1_0.article_id, k1_0.created_at, k1_0.is_deleted, k1_0.updated_at from koin_notice k1_0 where k1_0.article_id = ? and ( k1_0.is_deleted = ? )new_articles과 new_koin_articles, new_koreatech_articles, lost_item_articles, koin_notice의 OneToOne 관계로 인해 발생하는 문제이다.
new_articles은 연관관계의 주인이 아니기 때문에 직접 참조하기 전까지는 연관 객체를 가지고 있는지 확인할 수 없다.
그렇기 때문에 Hibernate에서는 new_articles에서 LAZY로 설정했더라도 조회하는 시점에서 연관 객체를 즉시 로딩한다.
해당 문제를 개선한다.
close [공통] Article 1+4N 문제 해결 #2266
🚀 주요 변경 내용
-> DTO Project으로 Article를 조회하도록 수정
💬 참고 사항
✅ Checklist (완료 조건)
Summary by CodeRabbit