[Refactor] 채용공고 추출 검색 변경 (#27)#60
Conversation
📝 WalkthroughWalkthroughThis PR makes three focused changes: it refines job posting search queries to exclude unstructured raw text fields, adds comprehensive test coverage for that structured search behavior, and adjusts the default credit allocation for newly created users from 0 to 1. ChangesJob Posting Search Query Refinement
User Credit Initialization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingClassificationService.java (1)
20-24:⚠️ Potential issue | 🟠 Major | ⚡ Quick winGuard against empty structured query before repository search.
When structured fields are all empty/null,
buildSearchQuery(...)returns"", but Line 23 still executes trigram search. That can return noisy candidates and trigger unnecessary full-scope DB work.Suggested fix
public List<JobPostingClassificationCandidateResponse> findCandidates(JobPostingExtractResponse extracted, int limit) { String query = buildSearchQuery(extracted); + if (query.isBlank()) { + return List.of(); + } return detailClassificationRepository.findTopCandidatesByTrigram(query, limit).stream() .map(this::toResponse) .toList(); }Also applies to: 28-35
🤖 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/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingClassificationService.java` around lines 20 - 24, The method findCandidates currently calls buildSearchQuery(extracted) and unconditionally invokes detailClassificationRepository.findTopCandidatesByTrigram(query, limit) even when the structured query is empty, causing noisy/expensive DB work; update findCandidates (and the similar flow around lines 28-35) to check if the returned query is null or empty (e.g., trim().isEmpty()) and return an empty List<JobPostingClassificationCandidateResponse> immediately instead of calling detailClassificationRepository.findTopCandidatesByTrigram; keep using the existing toResponse mapper for non-empty queries so behavior is unchanged for valid queries.
🧹 Nitpick comments (1)
src/test/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingClassificationServiceTest.java (1)
29-57: ⚡ Quick winAdd a blank-structured-fields test case.
Current coverage is good for “rawText exclusion,” but it doesn’t protect the edge case where structured fields are empty and only rawText has text. Add a test asserting no candidate search is performed (or empty result is returned) for that input.
🤖 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/test/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingClassificationServiceTest.java` around lines 29 - 57, Add a new unit test alongside findCandidatesUsesStructuredFieldsOnly that constructs a JobPostingExtractResponse whose structured fields (title, subtitle, sections, requirements, benefits, tags) are empty or blank while rawText contains non-empty text, then call jobPostingClassificationService.findCandidates(extracted, 5) and assert that detailClassificationRepository.findTopCandidatesByTrigram is not invoked (or returns an empty list) to verify no candidate search occurs for inputs with only rawText; reference the existing test method name findCandidatesUsesStructuredFieldsOnly, the JobPostingExtractResponse constructor usage, jobPostingClassificationService.findCandidates(...) call, and detailClassificationRepository.findTopCandidatesByTrigram(...) when implementing this new test.
🤖 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.
Outside diff comments:
In
`@src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingClassificationService.java`:
- Around line 20-24: The method findCandidates currently calls
buildSearchQuery(extracted) and unconditionally invokes
detailClassificationRepository.findTopCandidatesByTrigram(query, limit) even
when the structured query is empty, causing noisy/expensive DB work; update
findCandidates (and the similar flow around lines 28-35) to check if the
returned query is null or empty (e.g., trim().isEmpty()) and return an empty
List<JobPostingClassificationCandidateResponse> immediately instead of calling
detailClassificationRepository.findTopCandidatesByTrigram; keep using the
existing toResponse mapper for non-empty queries so behavior is unchanged for
valid queries.
---
Nitpick comments:
In
`@src/test/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingClassificationServiceTest.java`:
- Around line 29-57: Add a new unit test alongside
findCandidatesUsesStructuredFieldsOnly that constructs a
JobPostingExtractResponse whose structured fields (title, subtitle, sections,
requirements, benefits, tags) are empty or blank while rawText contains
non-empty text, then call
jobPostingClassificationService.findCandidates(extracted, 5) and assert that
detailClassificationRepository.findTopCandidatesByTrigram is not invoked (or
returns an empty list) to verify no candidate search occurs for inputs with only
rawText; reference the existing test method name
findCandidatesUsesStructuredFieldsOnly, the JobPostingExtractResponse
constructor usage, jobPostingClassificationService.findCandidates(...) call, and
detailClassificationRepository.findTopCandidatesByTrigram(...) when implementing
this new test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0bd5a96f-2689-4851-b7f0-d2238a3c4f21
📒 Files selected for processing (3)
src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingClassificationService.javasrc/main/java/com/jobdri/jobdri_api/domain/user/entity/User.javasrc/test/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingClassificationServiceTest.java
✨ 어떤 이유로 PR를 하셨나요?
📋 세부 내용 - 왜 해당 PR이 필요한지 작업 내용을 자세하게 설명해주세요
JD 추출 시 raw text기반 검색에서 기업명에 검색이 끌려가는 현상을 방지하고자
해당 필드로 검색을 수행해서 candidate 반환 후 confidence 높은 직무 추출
📸 작업 화면 스크린샷
🚨 관련 이슈 번호 [#27]
Summary by CodeRabbit
New Features
Improvements