Skip to content

[REFACTOR] 파트너 검색 API 필터링 제거 및 개선#57

Merged
Takch02 merged 6 commits into
mainfrom
feat/partners-search
May 20, 2026
Merged

[REFACTOR] 파트너 검색 API 필터링 제거 및 개선#57
Takch02 merged 6 commits into
mainfrom
feat/partners-search

Conversation

@Takch02

@Takch02 Takch02 commented May 19, 2026

Copy link
Copy Markdown
Contributor

Resolves #56

변경 요약

파트너 검색에서 드롭다운 기반 필터를 제거하고,
쿼리 텍스트 분석으로 국가를 자동 감지하는 방식으로 전환.

주요 변경

  • GET /partners/search — industry/country/partnership/size 파라미터 제거
  • COUNTRY_QUERY_MAP: 한국어/영어 국가명 → 검색 필터 자동 변환
  • RRF 중복 제거, 벡터 후보 수 100→500 확대
  • 결과 3개 미만 시 웹 폴백 (기존: 0개일 때만)

Summary by CodeRabbit

릴리스 노트

  • Bug Fixes

    • 검색 결과 병합 시 중복된 파트너명 제거 로직 추가
    • 웹 검색 폴백 조건 개선 (검색 결과 3개 미만일 때 작동)
  • 개선 사항

    • 파트너 검색 API 쿼리 파라미터 단순화
    • 검색 쿼리에서 국가 자동 감지 기능 추가
    • 벡터/텍스트 검색 파이프라인 최적화
  • Documentation

    • README에서 테스트넷 Faucet 링크 안내 제거

Review Change Stack

Takch02 and others added 3 commits May 19, 2026 16:07
industry / country / partnership / size 쿼리 파라미터를 API에서 제거.
국가 감지는 서비스 레이어에서 쿼리 텍스트를 분석해 자동으로 처리하는 방식으로 전환.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- COUNTRY_QUERY_MAP + detectCountryFromQuery: 쿼리 텍스트에서 국가명(한/영) 자동 감지
- 명시적 industry/country/partnership/size 필터 및 INDUSTRY_MAPPING 제거
- filter-only browsing(1.8) 제거, 쿼리 없을 때 전체 조회로 단일화
- RRF 중복 이름 제거 (seenNames)
- 벡터 후보 수 확대: numCandidates 100→500, limit 100→200
- 웹 폴백 임계값 조정: dbResults.length === 0 → < 3

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
프로젝트 소개, 핵심 가치, 기술 스택, 아키텍처 다이어그램, API 엔드포인트,
비즈니스 모델 섹션 추가. 빠른 시작 가이드 구체화.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Takch02 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 34 minutes and 4 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 08ec7054-958a-4c8a-b3c5-52e3034c74a4

📥 Commits

Reviewing files that changed from the base of the PR and between 2f2dee6 and 66e9966.

📒 Files selected for processing (1)
  • src/modules/partners/partners.service.ts
📝 Walkthrough

Walkthrough

파트너 검색 API 엔드포인트에서 industry/country/partnership/size 필터 파라미터를 제거하고, 쿼리 텍스트에서 국가를 자동으로 감지하는 메커니즘을 도입했습니다. RRF 병합 후 회사명 중복을 제거하고 웹 폴백 임계값을 조정했으며, 모든 테스트를 업데이트했습니다.

Changes

파트너 검색 API 필터 간소화 및 국가 자동 감지

Layer / File(s) Summary
검색 API 계약 간소화
src/modules/partners/partners.controller.ts, src/modules/partners/partners.service.ts
PartnersController의 search 엔드포인트에서 industry, country, partnership, size 쿼리 파라미터를 제거하고, SearchOptions 인터페이스에서 해당 필터 필드를 삭제한 후 buyerId와 userId만 남겼습니다.
쿼리 기반 국가 자동 감지 메커니즘
src/modules/partners/partners.service.ts
COUNTRY_QUERY_MAP 상수와 detectCountryFromQuery() 함수를 추가하여 쿼리 문자열에서 한국어/영어 국가명을 감지합니다. search() 메서드에서 opts를 재구성하고 detectedCountry를 초기화한 후 검색 로직에 반영합니다.
텍스트 및 벡터 검색 파이프라인 업데이트
src/modules/partners/partners.service.ts
DB 검색 조건을 단순화하고, 텍스트/벡터 검색 필터에 detectedCountry 기반 정규식을 적용하며, 벡터 검색 파라미터 및 로깅을 개선했습니다.
결과 중복 제거 및 웹 폴백 조정
src/modules/partners/partners.service.ts
RRF 병합 후 회사명(name 또는 name_kr) 기준으로 중복을 제거하는 seenNames 로직을 도입하고, 웹 검색 폴백 임계값을 DB 결과 3개 미만으로 조정했습니다.
테스트 스위트 업데이트
src/modules/partners/partners.controller.spec.ts, src/modules/partners/partners.service.spec.ts
PartnersController와 PartnersService 테스트를 API 계약 변경 및 새로운 검색 로직에 맞춰 업데이트했습니다. browse 모드 테스트 케이스를 재구성하고 텍스트/벡터 검색 테스트 데이터를 확장했습니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • K-Statra/backend#55: PartnersService.search의 RRF(Reciprocal Rank Fusion) 병합 로직에서 결과 합산 및 중복 제거 기능이 직접 맞닿아 있습니다.
  • K-Statra/backend#23: PartnersController/PartnersService에서 userId 추가 및 savedPartners 제외 로직이 이번 PR의 userId 옵션 추가와 직접 연관됩니다.

Poem

필터는 걷어내고 국가는 감지하네 🌍
쿼리 텍스트 속 한글과 영문을 찾아
RRF 결과 중복은 제거하고 ✨
세 개 미만 땐 웹으로 폴백
파트너 검색, 이제는 더 똑똑하네 🚀

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 주요 변경사항(필터 파라미터 제거 및 자동 국가 감지)을 명확하게 요약하고 있으며, 실제 코드 변경과 일치합니다.
Linked Issues check ✅ Passed PR의 모든 코드 변경사항이 #56의 요구사항을 충족합니다: 필터 파라미터 제거, 국가 자동 감지, RRF 중복 제거, 벡터 후보 수 확대, 웹 폴백 임계값 조정.
Out of Scope Changes check ✅ Passed README.md 링크 삭제를 제외한 모든 변경이 파트너 검색 API 필터 개선과 직결되어 있으며, 범위 내의 변경입니다.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/partners-search

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.

@Takch02

Takch02 commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 2

🧹 Nitpick comments (1)
src/modules/partners/partners.service.ts (1)

296-298: ⚡ Quick win

벡터 검색 에러 로깅에서 원인 정보가 유실될 수 있습니다.

JSON.stringify(err)는 Error 객체에서 {}가 나오는 경우가 많아 장애 분석이 어려워집니다. message 기반 로그로 바꾸는 편이 안전합니다.

🔧 제안 수정안
-          this.logger.error(
-            `[Search] Vector search error: ${JSON.stringify(err)}`,
-          );
+          this.logger.error(
+            `[Search] Vector search error: ${err?.message ?? String(err)}`,
+          );
🤖 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/modules/partners/partners.service.ts` around lines 296 - 298, The current
vector-search error log uses JSON.stringify(err) which often yields "{}" for
Error objects; update the logging in the vector search error path (the
this.logger.error call inside the vector search handling in partners.service.ts)
to log meaningful error details such as err.message and err.stack (or fallback
to String(err)) instead of JSON.stringify(err) so callers get the actual cause
and stack trace for debugging.
🤖 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/modules/partners/partners.service.ts`:
- Around line 1009-1014: The detectCountryFromQuery function currently uses
substring includes on qLower against entries in COUNTRY_QUERY_MAP which causes
false positives (e.g., "truck" matching "uk"); update the matching to use
whole-word/phrase matching instead of includes: normalize qLower and each kr/en
to lowercase, and for each entry test either tokenized word membership (split
qLower on non-alphanumeric boundaries and compare exact tokens) or construct a
word-boundary-aware regex for the kr and en values (using \b ... \b) so
multi-word phrases still match correctly; change the loop in
detectCountryFromQuery to use this exact-token or \b-regex test against kr and
en rather than simple includes.
- Around line 348-353: The filter that deduplicates partners uses only (r.name
|| r.name_kr) to build the key, so records that have only an English-only field
(nameEn or name_en) are treated as empty and dropped; update the deduplication
key logic inside the .filter callback (the function that computes key and uses
seenNames) to include the English name field(s) as fallbacks (e.g., r.nameEn or
r.name_en) and consistently normalize/trim the selected value before checking
seenNames so English-only partners are preserved and de-duplicated correctly.

---

Nitpick comments:
In `@src/modules/partners/partners.service.ts`:
- Around line 296-298: The current vector-search error log uses
JSON.stringify(err) which often yields "{}" for Error objects; update the
logging in the vector search error path (the this.logger.error call inside the
vector search handling in partners.service.ts) to log meaningful error details
such as err.message and err.stack (or fallback to String(err)) instead of
JSON.stringify(err) so callers get the actual cause and stack trace for
debugging.
🪄 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: 5a4bd3e6-e120-4277-835c-3168e94bfe5a

📥 Commits

Reviewing files that changed from the base of the PR and between 048f4a9 and 2f2dee6.

📒 Files selected for processing (5)
  • README.md
  • src/modules/partners/partners.controller.spec.ts
  • src/modules/partners/partners.controller.ts
  • src/modules/partners/partners.service.spec.ts
  • src/modules/partners/partners.service.ts
💤 Files with no reviewable changes (2)
  • README.md
  • src/modules/partners/partners.controller.ts

Comment thread src/modules/partners/partners.service.ts
Comment thread src/modules/partners/partners.service.ts Outdated
@Takch02 Takch02 merged commit c477bda into main May 20, 2026
3 checks passed
@Takch02 Takch02 deleted the feat/partners-search branch May 20, 2026 00:43
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.

[REFACTOR] 파트너 검색 API 필터 방식 개선

1 participant