Skip to content

fix: 키워드 페이징 조회를 단건 조회로 수정#2216

Merged
Soundbar91 merged 4 commits intodevelopfrom
fix/keyword-extractor
Apr 8, 2026
Merged

fix: 키워드 페이징 조회를 단건 조회로 수정#2216
Soundbar91 merged 4 commits intodevelopfrom
fix/keyword-extractor

Conversation

@Soundbar91
Copy link
Copy Markdown
Collaborator

@Soundbar91 Soundbar91 commented Apr 8, 2026

🔍 개요


🚀 주요 변경 내용

  • 키워드 알림 테스트를 위해 페이징 조회를 단건 조회로 수정했습니다.

💬 참고 사항


✅ Checklist (완료 조건)

  • 코드 스타일 가이드 준수
  • 테스트 코드 포함됨
  • Reviewers / Assignees / Labels 지정 완료
  • 보안 및 민감 정보 검증 (API 키, 환경 변수, 개인정보 등)

Summary by CodeRabbit

  • Refactor
    • Simplified keyword extraction to load and process the full keyword set in one pass, removing batched pagination and streamlining matching across articles for more predictable performance.
  • Tests
    • Updated unit tests to reflect the new single-pass keyword retrieval approach.

@Soundbar91 Soundbar91 self-assigned this Apr 8, 2026
@github-actions github-actions bot added the 버그 정상적으로 동작하지 않는 문제상황입니다. label Apr 8, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 32951c01-f936-4b50-8452-f13a635bce19

📥 Commits

Reviewing files that changed from the base of the PR and between 97bf224 and 70b2b05.

📒 Files selected for processing (1)
  • src/test/java/in/koreatech/koin/unit/domain/community/util/KeywordExtractorTest.java

📝 Walkthrough

Walkthrough

The pull request adds an unpaginated findAll() overload to ArticleKeywordRepository and refactors KeywordExtractor to fetch all keywords in a single call instead of iterating paginated batches; tests updated to stub the new repository method.

Changes

Cohort / File(s) Summary
Repository API Addition
src/main/java/in/koreatech/koin/domain/community/keyword/repository/ArticleKeywordRepository.java
Added List<ArticleKeyword> findAll() overload to return all ArticleKeyword entities without Pageable.
Keyword Extraction Refactor
src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java
Removed paginated batch loop (PageRequest/while(true) with offset). Now loads all keywords once via articleKeywordRepository.findAll(), then proceeds with existing mapping/matching logic.
Tests Updated
src/test/java/in/koreatech/koin/unit/domain/community/util/KeywordExtractorTest.java
Replaced mocks/stubs that expected findAll(Pageable) with stubs for findAll(); removed Pageable import and paginated return sequences.

Sequence Diagram(s)

sequenceDiagram
    participant Extractor as KeywordExtractor
    participant RepoKW as ArticleKeywordRepository
    participant RepoMap as ArticleKeywordUserMapRepository
    participant DB as Database

    Extractor->>RepoKW: findAll()
    RepoKW->>DB: query all ArticleKeyword rows
    DB-->>RepoKW: list of ArticleKeyword
    RepoKW-->>Extractor: List<ArticleKeyword>

    Extractor->>RepoMap: findAllByKeywordIdIn(nonDeletedIds)
    RepoMap->>DB: query ArticleKeywordUserMap by keyword IDs and not-deleted
    DB-->>RepoMap: list of mappings
    RepoMap-->>Extractor: List<ArticleKeywordUserMap>

    Extractor->>Extractor: build matchedKeywordByUserIdByArticleId(articles, mappings)
    Extractor-->>Caller: matched results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • kih1015
  • kongwoojin
  • skdud0629

Poem

🐰 I hopped through code to find a way,
No paging loops to lead astray.
One gentle call, all keywords found,
I matched them up without a bound.
Hooray — fewer hops, more springtime play! 🌷

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: converting keyword pagination retrieval to single retrieval, which aligns with the core modification across repository, extractor, and test files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/keyword-extractor

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Unit Test Results

665 tests   656 ✔️  1m 18s ⏱️
164 suites      9 💤
164 files        0

Results for commit 70b2b05.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java`:
- Around line 29-46: The current implementation in KeywordExtractor loads all
ArticleKeyword rows and then calls
articleKeywordUserMapRepository.findAllByArticleKeywordIdIn over every id,
causing unbounded memory/latency when matchKeyword() is called during lost-item
creation; change this to a paged/batched scan: iterate ArticleKeyword pages (use
ArticleKeywordRepository pageable/streaming API) and for each page collect its
ids and call articleKeywordUserMapRepository.findAllByArticleKeywordIdIn for
just that batch (or use a repository method that accepts a page/stream), build
the userMapsByKeywordId incrementally (merging per-page results) and keep
filtering out deleted ArticleKeywordUserMap entries as before so memory and
latency scale with the input batch rather than the whole table.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91f5a1fa-498e-4560-b1a3-f1b06d171826

📥 Commits

Reviewing files that changed from the base of the PR and between 674e3a0 and 97bf224.

📒 Files selected for processing (2)
  • src/main/java/in/koreatech/koin/domain/community/keyword/repository/ArticleKeywordRepository.java
  • src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java

Comment on lines +29 to +46
List<ArticleKeyword> keywords = articleKeywordRepository.findAll();

while (true) {
Pageable pageable = PageRequest.of(offset / KEYWORD_BATCH_SIZE, KEYWORD_BATCH_SIZE);
List<ArticleKeyword> keywords = articleKeywordRepository.findAll(pageable);
if (keywords.isEmpty()) {
return List.of();
}

if (keywords.isEmpty()) {
break;
}
List<Integer> keywordIds = keywords.stream()
.map(ArticleKeyword::getId)
.toList();
Map<Integer, List<ArticleKeywordUserMap>> userMapsByKeywordId = articleKeywordUserMapRepository
.findAllByArticleKeywordIdIn(keywordIds)
.stream()
.filter(keywordUserMap -> !keywordUserMap.getIsDeleted())
.collect(Collectors.groupingBy(
keywordUserMap -> keywordUserMap.getArticleKeyword().getId(),
LinkedHashMap::new,
Collectors.toList()
));
List<Integer> keywordIds = keywords.stream()
.map(ArticleKeyword::getId)
.toList();
Map<Integer, List<ArticleKeywordUserMap>> userMapsByKeywordId = articleKeywordUserMapRepository
.findAllByArticleKeywordIdIn(keywordIds)
.stream()
.filter(keywordUserMap -> !keywordUserMap.getIsDeleted())
.collect(Collectors.groupingBy(
keywordUserMap -> keywordUserMap.getArticleKeyword().getId(),
LinkedHashMap::new,
Collectors.toList()
));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Keep the paged scan on this request path.

This now loads the full ArticleKeyword table and then issues an unbounded findAllByArticleKeywordIdIn(keywordIds) over every keyword id before checking a few titles. src/main/java/in/koreatech/koin/domain/community/article/service/LostItemArticleService.java:173-186 and 254-261 call matchKeyword() during lost-item creation, so latency and memory now grow with total keyword volume instead of the current articles input. Please keep the batched/paged scan here, or move the full scan behind a cached/background path if this is only needed for testing.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java`
around lines 29 - 46, The current implementation in KeywordExtractor loads all
ArticleKeyword rows and then calls
articleKeywordUserMapRepository.findAllByArticleKeywordIdIn over every id,
causing unbounded memory/latency when matchKeyword() is called during lost-item
creation; change this to a paged/batched scan: iterate ArticleKeyword pages (use
ArticleKeywordRepository pageable/streaming API) and for each page collect its
ids and call articleKeywordUserMapRepository.findAllByArticleKeywordIdIn for
just that batch (or use a repository method that accepts a page/stream), build
the userMapsByKeywordId incrementally (merging per-page results) and keep
filtering out deleted ArticleKeywordUserMap entries as before so memory and
latency scale with the input batch rather than the whole table.

Copy link
Copy Markdown
Contributor

@dh2906 dh2906 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

화이팅 화이팅!!

@Soundbar91 Soundbar91 merged commit b180c94 into develop Apr 8, 2026
7 checks passed
@Soundbar91 Soundbar91 deleted the fix/keyword-extractor branch April 8, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

버그 정상적으로 동작하지 않는 문제상황입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants