Skip to content

Commit 15b41e7

Browse files
committed
fix: 불필요한 검증 로직 삭제
1 parent fef1319 commit 15b41e7

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.springframework.stereotype.Service;
1212
import org.springframework.transaction.annotation.Transactional;
1313

14-
import in.koreatech.koin.domain.community.article.exception.ArticleNotFoundException;
14+
import in.koreatech.koin.common.event.ArticleKeywordEvent;
1515
import in.koreatech.koin.domain.community.article.dto.ArticleKeywordResult;
1616
import in.koreatech.koin.domain.community.article.model.Article;
1717
import in.koreatech.koin.domain.community.article.repository.ArticleRepository;
@@ -23,7 +23,6 @@
2323
import in.koreatech.koin.domain.community.keyword.exception.KeywordDuplicationException;
2424
import in.koreatech.koin.domain.community.keyword.exception.KeywordLimitExceededException;
2525
import in.koreatech.koin.domain.community.keyword.model.ArticleKeyword;
26-
import in.koreatech.koin.common.event.ArticleKeywordEvent;
2726
import in.koreatech.koin.domain.community.keyword.model.ArticleKeywordSuggestCache;
2827
import in.koreatech.koin.domain.community.keyword.model.ArticleKeywordUserMap;
2928
import in.koreatech.koin.domain.community.keyword.repository.ArticleKeywordRepository;
@@ -151,19 +150,7 @@ public void sendKeywordNotification(KeywordNotificationRequest request) {
151150
return;
152151
}
153152

154-
List<Article> fetchedArticles = articleRepository.findAllByIdIn(request.updateNotification());
155-
var articleById = fetchedArticles.stream()
156-
.collect(Collectors.toMap(Article::getId, article -> article));
157-
List<Article> articles = request.updateNotification().stream()
158-
.map(articleId -> {
159-
Article article = articleById.get(articleId);
160-
if (article == null) {
161-
throw ArticleNotFoundException.withDetail("articleId: " + articleId);
162-
}
163-
return article;
164-
})
165-
.toList();
166-
153+
List<Article> articles = articleRepository.findAllByIdIn(request.updateNotification());
167154
List<ArticleKeywordEvent> keywordEvents = keywordExtractor.matchKeyword(articles, null);
168155
for (ArticleKeywordEvent event : keywordEvents) {
169156
eventPublisher.publishEvent(event);

0 commit comments

Comments
 (0)