From 8a90b5478d6f905e647fb04745a18ba3af594421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 27 May 2026 11:38:03 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=82=A4=EC=9B=8C=EB=93=9C=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=84=A4=EC=9D=B4=EC=85=98=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ArticleKeywordRepository.java | 2 +- .../community/util/KeywordExtractor.java | 21 ++++--------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/community/keyword/repository/ArticleKeywordRepository.java b/src/main/java/in/koreatech/koin/domain/community/keyword/repository/ArticleKeywordRepository.java index 1ff78c6f9..aac5ea0de 100644 --- a/src/main/java/in/koreatech/koin/domain/community/keyword/repository/ArticleKeywordRepository.java +++ b/src/main/java/in/koreatech/koin/domain/community/keyword/repository/ArticleKeywordRepository.java @@ -31,7 +31,7 @@ Optional findByKeywordAndCategoryIncludingDeleted( Optional findById(Integer id); - List findAllByCategory(KeywordCategory category, Pageable pageable); + List findAllByCategory(KeywordCategory category); @Query(""" SELECT new in.koreatech.koin.domain.community.article.dto.ArticleKeywordResult(k.id, k.keyword, COUNT(u)) diff --git a/src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java b/src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java index f0a59f69b..5bc43decf 100644 --- a/src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java +++ b/src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java @@ -3,8 +3,6 @@ import java.util.ArrayList; import java.util.List; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -18,27 +16,16 @@ @Transactional(readOnly = true) public class KeywordExtractor { - private static final int KEYWORD_BATCH_SIZE = 100; - private final ArticleKeywordRepository articleKeywordRepository; public List matchKeywords(String title, KeywordCategory category) { List matchedKeywords = new ArrayList<>(); - int offset = 0; - - while (true) { - Pageable pageable = PageRequest.of(offset / KEYWORD_BATCH_SIZE, KEYWORD_BATCH_SIZE); - List keywords = articleKeywordRepository.findAllByCategory(category, pageable); + List keywords = articleKeywordRepository.findAllByCategory(category); - if (keywords.isEmpty()) { - break; - } - for (ArticleKeyword keyword : keywords) { - if (title.contains(keyword.getKeyword())) { - matchedKeywords.add(keyword.getKeyword()); - } + for (ArticleKeyword keyword : keywords) { + if (title.contains(keyword.getKeyword())) { + matchedKeywords.add(keyword.getKeyword()); } - offset += KEYWORD_BATCH_SIZE; } return matchedKeywords;