Skip to content

feat: 키워드 검색 집계 추가#102

Merged
buddle031 merged 4 commits into
mainfrom
feat/keyword-search-count
Jun 27, 2026
Merged

feat: 키워드 검색 집계 추가#102
buddle031 merged 4 commits into
mainfrom
feat/keyword-search-count

Conversation

@buddle031

@buddle031 buddle031 commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

✨ 작업 내용 한 줄 요약

  • /lockers/keyword 검색 시 키워드 검색 횟수를 누적 집계하는 기능을 추가했습니다.

🛠️ 작업 내용

  • KeywordCount 집계용 Entity 및 Repository 추가
  • 키워드 검색 횟수 증가를 담당하는 KeywordCountCommandService 추가
  • /lockers/keyword 조회 시 키워드 검색 횟수 집계 로직 추가
  • PostgreSQL ON CONFLICT 기반 upsert 방식으로 검색 횟수 누적
  • 집계 저장 실패 시 검색 기능은 정상 동작하도록 예외 처리 추가
  • 로컬 DB 초기화를 위한 keyword_counts 스키마(SQL) 추가

🧠 기술적 의사결정

  • 조회 성능과 동시성을 고려하여 조회 후 저장 대신 PostgreSQL ON CONFLICT 기반 upsert를 사용했습니다.
  • 키워드 집계는 검색 기능의 부가 기능이므로 집계 실패가 검색 API 응답에 영향을 주지 않도록 예외를 분리했습니다.
  • 운영 환경은 ddl-auto: validate를 사용하므로, 신규 테이블은 별도 SQL 스키마로 관리하도록 구성했습니다.

📚 참고 자료 (선택)

📷 스크린샷 (선택)

Summary by CodeRabbit

  • 새 기능

    • 검색어 사용량을 저장해, 인기 검색어 집계 기반을 추가했습니다.
    • 검색어 입력값은 공백을 정리한 뒤 저장되어 더 일관되게 처리됩니다.
  • 버그 수정

    • 검색어 저장 중 일부 오류가 발생해도 검색 결과 조회는 계속 진행되도록 개선했습니다.
  • 기타

    • 초기 데이터베이스 설정에 검색어 집계용 항목이 포함되었습니다.

@buddle031 buddle031 requested a review from mike7643 as a code owner June 27, 2026 06:34
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@buddle031, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 32 minutes and 27 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d1392318-8af4-4807-9827-15a863c2f466

📥 Commits

Reviewing files that changed from the base of the PR and between c905022 and 56eb026.

📒 Files selected for processing (2)
  • src/main/java/com/zimdugo/locker/application/keyword/LockerKeywordQueryService.java
  • src/test/java/com/zimdugo/locker/application/keyword/LockerKeywordQueryServiceTest.java
📝 Walkthrough

Walkthrough

키워드 검색 요청에서 검색어 사용량을 별도 트랜잭션으로 증가시키는 경로가 추가되었습니다. 이를 위해 키워드 카운트 테이블, JPA 엔티티/리포지토리, 저장소 어댑터, 서비스 계층과 로컬 SQL 초기화 설정이 함께 변경되었습니다.

Changes

키워드 카운트 기록

Layer / File(s) Summary
스키마 초기화
scripts/db/03-keyword-counts.sql, src/main/resources/application-local.yaml
keyword_counts 테이블과 인덱스를 생성하고, 로컬 SQL 초기화 목록에 해당 스크립트를 추가합니다.
저장소 계약과 구현
src/main/java/com/zimdugo/locker/domain/keyword/KeywordCountStore.java, src/main/java/com/zimdugo/locker/infrastructure/persistence/KeywordCountEntity.java, src/main/java/com/zimdugo/locker/infrastructure/persistence/KeywordCountRepository.java, src/main/java/com/zimdugo/locker/infrastructure/adapter/KeywordCountStoreAdapter.java
KeywordCountStore 계약과 JPA 엔티티, search_count 증가 업서트 리포지토리, 이를 위임하는 어댑터가 추가됩니다.
검색 경로 기록
src/main/java/com/zimdugo/locker/application/keyword/KeywordCountCommandService.java, src/main/java/com/zimdugo/locker/application/keyword/LockerKeywordQueryService.java
키워드를 정규화해 별도 트랜잭션으로 증가시키고, 검색 서비스는 호출 초기에 기록을 남긴 뒤 데이터 접근 오류를 경고로만 처리합니다.

Sequence Diagram(s)

sequenceDiagram
  participant LockerKeywordQueryService
  participant KeywordCountCommandService
  participant KeywordCountStoreAdapter
  participant KeywordCountRepository
  participant keyword_counts
  participant LockerSearchQueryService

  LockerKeywordQueryService->>KeywordCountCommandService: increase(keyword)
  KeywordCountCommandService->>KeywordCountStoreAdapter: increase(normalizedKeyword)
  KeywordCountStoreAdapter->>KeywordCountRepository: increase(keyword)
  KeywordCountRepository->>keyword_counts: upsert search_count
  LockerKeywordQueryService->>LockerSearchQueryService: getKeywordResults(...)
Loading

Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

나는 토끼, 폴짝 폴짝 키워드 밭을 달려
search_count 씨앗을 살짝 심었지 🐇
trim 된 말만 골라 반짝 남기고
검색 길목엔 조용한 기록이 쌓여
달빛 아래 결과도 폴짝, 숫자도 폴짝

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 키워드 검색 횟수 집계 추가라는 핵심 변경을 간결하게 잘 요약합니다.
Description check ✅ Passed 템플릿의 필수 섹션을 모두 포함하고 있으며 작업 내용과 기술적 의사결정도 충분히 설명합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/keyword-search-count

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/db/03-keyword-counts.sql (1)

8-9: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

중복 인덱스 제거 UNIQUE (keyword)가 이미 keyword용 인덱스를 생성하므로, CREATE INDEX는 중복입니다. 제거하세요.

🤖 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 `@scripts/db/03-keyword-counts.sql` around lines 8 - 9, The CREATE INDEX on
keyword_counts.keyword is redundant because the UNIQUE constraint already
creates an index for that column. Remove the extra index definition from the SQL
migration, keeping only the UNIQUE (keyword) constraint so the keyword_counts
table is indexed once through the existing unique key.
🤖 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.

Inline comments:
In
`@src/main/java/com/zimdugo/locker/application/keyword/LockerKeywordQueryService.java`:
- Around line 156-162: The keyword count update in increaseKeywordCount only
catches DataAccessException, so failures from the REQUIRES_NEW commit path can
still escape and break the search flow. Update
LockerKeywordQueryService.increaseKeywordCount to also handle
TransactionException alongside DataAccessException, and keep the warning log
path unchanged so keyword aggregation failures remain non-fatal.

---

Nitpick comments:
In `@scripts/db/03-keyword-counts.sql`:
- Around line 8-9: The CREATE INDEX on keyword_counts.keyword is redundant
because the UNIQUE constraint already creates an index for that column. Remove
the extra index definition from the SQL migration, keeping only the UNIQUE
(keyword) constraint so the keyword_counts table is indexed once through the
existing unique key.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 13be7248-d0ec-4c77-b166-f9ec28786d71

📥 Commits

Reviewing files that changed from the base of the PR and between 7b26cfc and c905022.

📒 Files selected for processing (8)
  • scripts/db/03-keyword-counts.sql
  • src/main/java/com/zimdugo/locker/application/keyword/KeywordCountCommandService.java
  • src/main/java/com/zimdugo/locker/application/keyword/LockerKeywordQueryService.java
  • src/main/java/com/zimdugo/locker/domain/keyword/KeywordCountStore.java
  • src/main/java/com/zimdugo/locker/infrastructure/adapter/KeywordCountStoreAdapter.java
  • src/main/java/com/zimdugo/locker/infrastructure/persistence/KeywordCountEntity.java
  • src/main/java/com/zimdugo/locker/infrastructure/persistence/KeywordCountRepository.java
  • src/main/resources/application-local.yaml

@buddle031 buddle031 merged commit 85f862c into main Jun 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant