-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#38 mock jobposting with data #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shinae1023
wants to merge
7
commits into
main
Choose a base branch
from
feat/#38-mock-jobposting-with-data
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3359aa0
[Feat] 자소서 분석 시 유사한 공고와 질문 함께 포함 (#24)
shinae1023 7a16249
[Feat] 유사 jd 확인 admin API (#24)
shinae1023 4b72e3e
[Feat] 유사 jd 검색 기준을 추출한 jobposting으로 설정 (#24)
shinae1023 e1fe657
[Feat] jd 검색 fallback 로직 추가 (#24)
shinae1023 ab389af
[Fix] 코드리뷰 반영 (#26)
shinae1023 31762f7
[Feat] 공용 corpus retrieval 기반 분석/모의공고 흐름 연결 (#38)
shinae1023 bd98089
[Fix] 코드리뷰 반영 (#38)
shinae1023 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| -- Manual migration for environments that already have embedding tables created | ||
| -- with an unbounded vector column. Run after backing up the database. | ||
|
|
||
| CREATE EXTENSION IF NOT EXISTS vector; | ||
|
|
||
| DO $$ | ||
| BEGIN | ||
| IF EXISTS ( | ||
| SELECT 1 | ||
| FROM information_schema.columns | ||
| WHERE table_name = 'mock_job_posting_embeddings' | ||
| AND column_name = 'embedding' | ||
| ) THEN | ||
| ALTER TABLE mock_job_posting_embeddings | ||
| ALTER COLUMN embedding TYPE vector(1024); | ||
| END IF; | ||
| END $$; | ||
|
|
||
| DO $$ | ||
| BEGIN | ||
| IF EXISTS ( | ||
| SELECT 1 | ||
| FROM information_schema.columns | ||
| WHERE table_name = 'mock_question_embeddings' | ||
| AND column_name = 'embedding' | ||
| ) THEN | ||
| ALTER TABLE mock_question_embeddings | ||
| ALTER COLUMN embedding TYPE vector(1024); | ||
| END IF; | ||
| END $$; | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_mock_job_posting_embeddings_hnsw | ||
| ON mock_job_posting_embeddings USING hnsw (embedding vector_cosine_ops); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_mock_question_embeddings_hnsw | ||
| ON mock_question_embeddings USING hnsw (embedding vector_cosine_ops); |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/AnalysisAdminController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.jobdri.jobdri_api.domain.analysis.controller; | ||
|
|
||
| import com.jobdri.jobdri_api.domain.analysis.dto.request.AnalysisRetrievalPreviewRequest; | ||
| import com.jobdri.jobdri_api.domain.analysis.dto.response.AnalysisRetrievalPreviewResponse; | ||
| import com.jobdri.jobdri_api.domain.analysis.service.AnalysisAdminDebugService; | ||
| import com.jobdri.jobdri_api.global.apiPayload.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/admin/analysis") | ||
| @Tag(name = "AnalysisAdmin", description = "관리자용 자소서 분석 디버그 API") | ||
| public class AnalysisAdminController { | ||
|
|
||
| private final AnalysisAdminDebugService analysisAdminDebugService; | ||
|
|
||
| @Operation( | ||
| summary = "분석 retrieval 미리보기", | ||
| description = "mockApplyId를 기준으로 실제 분석 전에 조회되는 유사 JD/문항 검색 결과를 반환합니다." | ||
| ) | ||
| @PostMapping("/retrieval-preview") | ||
| public ApiResponse<AnalysisRetrievalPreviewResponse> previewRetrieval( | ||
| @Valid @RequestBody AnalysisRetrievalPreviewRequest request | ||
| ) { | ||
| return ApiResponse.onSuccess( | ||
| "분석 retrieval 미리보기에 성공했습니다.", | ||
| analysisAdminDebugService.previewRetrieval(request.mockApplyId()) | ||
| ); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
...va/com/jobdri/jobdri_api/domain/analysis/dto/request/AnalysisRetrievalPreviewRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.jobdri.jobdri_api.domain.analysis.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Positive; | ||
|
|
||
| public record AnalysisRetrievalPreviewRequest( | ||
| @NotNull(message = "mockApplyId는 필수입니다.") | ||
| @Positive(message = "mockApplyId는 1 이상이어야 합니다.") | ||
| Long mockApplyId | ||
| ) { | ||
| } |
50 changes: 50 additions & 0 deletions
50
.../com/jobdri/jobdri_api/domain/analysis/dto/response/AnalysisRetrievalPreviewResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package com.jobdri.jobdri_api.domain.analysis.dto.response; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record AnalysisRetrievalPreviewResponse( | ||
| Long mockApplyId, | ||
| JobPostingSnapshot jobPosting, | ||
| List<QuestionSnapshot> questions, | ||
| List<JobPostingReference> similarJobPostings, | ||
| List<QuestionReference> similarQuestions | ||
| ) { | ||
| public record JobPostingSnapshot( | ||
| Long jobPostingId, | ||
| String companyName, | ||
| String detailClassificationName, | ||
| String task, | ||
| String requirement, | ||
| String preferred | ||
| ) { | ||
| } | ||
|
|
||
| public record QuestionSnapshot( | ||
| Long questionId, | ||
| String content, | ||
| String answer | ||
| ) { | ||
| } | ||
|
|
||
| public record JobPostingReference( | ||
| Long corpusId, | ||
| String companyName, | ||
| String roleName, | ||
| String responsibilities, | ||
| String requirements, | ||
| String preferred, | ||
| double distance | ||
| ) { | ||
| } | ||
|
|
||
| public record QuestionReference( | ||
| Long corpusId, | ||
| String companyName, | ||
| String roleName, | ||
| String questionType, | ||
| Integer charLimit, | ||
| String questionText, | ||
| double distance | ||
| ) { | ||
| } | ||
| } |
80 changes: 80 additions & 0 deletions
80
src/main/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisAdminDebugService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package com.jobdri.jobdri_api.domain.analysis.service; | ||
|
|
||
| import com.jobdri.jobdri_api.domain.analysis.dto.response.AnalysisRetrievalPreviewResponse; | ||
| import com.jobdri.jobdri_api.domain.analysis.entity.Question; | ||
| import com.jobdri.jobdri_api.domain.analysis.repository.QuestionRepository; | ||
| import com.jobdri.jobdri_api.domain.corpus.service.CorpusRetrievalService; | ||
| import com.jobdri.jobdri_api.domain.corpus.service.CorpusRetrievalService.RetrievalContext; | ||
| import com.jobdri.jobdri_api.domain.jobposting.entity.JobPosting; | ||
| import com.jobdri.jobdri_api.domain.mockapply.entity.MockApply; | ||
| import com.jobdri.jobdri_api.domain.mockapply.repository.MockApplyRepository; | ||
| import com.jobdri.jobdri_api.global.apiPayload.code.GeneralErrorCode; | ||
| import com.jobdri.jobdri_api.global.apiPayload.exception.GeneralException; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class AnalysisAdminDebugService { | ||
|
|
||
| private final MockApplyRepository mockApplyRepository; | ||
| private final QuestionRepository questionRepository; | ||
| private final CorpusRetrievalService corpusRetrievalService; | ||
|
|
||
| public AnalysisRetrievalPreviewResponse previewRetrieval(Long mockApplyId) { | ||
| MockApply mockApply = mockApplyRepository.findByIdWithJobPosting(mockApplyId) | ||
| .orElseThrow(() -> new GeneralException( | ||
| GeneralErrorCode.MOCK_APPLY_NOT_FOUND, | ||
| "해당 모의 서류 지원을 찾을 수 없습니다. mockApplyId=" + mockApplyId | ||
| )); | ||
| List<Question> questions = questionRepository.findAllByMockApplyIdOrderByIdAsc(mockApplyId); | ||
| JobPosting jobPosting = mockApply.getJobPosting(); | ||
|
|
||
| RetrievalContext referenceContext = corpusRetrievalService.retrieveForAnalysis(jobPosting, questions); | ||
|
|
||
| return new AnalysisRetrievalPreviewResponse( | ||
| mockApply.getId(), | ||
| new AnalysisRetrievalPreviewResponse.JobPostingSnapshot( | ||
| jobPosting.getId(), | ||
| jobPosting.getCompany().getName(), | ||
| jobPosting.getDetailClassification().getDetailName(), | ||
| jobPosting.getTask(), | ||
| jobPosting.getRequirement(), | ||
| jobPosting.getPreferred() | ||
| ), | ||
| questions.stream() | ||
| .map(question -> new AnalysisRetrievalPreviewResponse.QuestionSnapshot( | ||
| question.getId(), | ||
| question.getContent(), | ||
| question.getAnswer() | ||
| )) | ||
| .toList(), | ||
| referenceContext.jobPostingReferences().stream() | ||
| .map(reference -> new AnalysisRetrievalPreviewResponse.JobPostingReference( | ||
| reference.corpusId(), | ||
| reference.companyName(), | ||
| reference.roleName(), | ||
| reference.responsibilities(), | ||
| reference.requirements(), | ||
| reference.preferred(), | ||
| reference.distance() | ||
| )) | ||
| .toList(), | ||
| referenceContext.questionReferences().stream() | ||
| .map(reference -> new AnalysisRetrievalPreviewResponse.QuestionReference( | ||
| reference.corpusId(), | ||
| reference.companyName(), | ||
| reference.roleName(), | ||
| reference.questionType(), | ||
| reference.charLimit(), | ||
| reference.questionText(), | ||
| reference.distance() | ||
| )) | ||
| .toList() | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.