Skip to content

[Feat] Add job posting sequence analysis lookup (#27)#89

Merged
shinae1023 merged 1 commit into
mainfrom
feat/#27-actual-apply-count
May 27, 2026
Merged

[Feat] Add job posting sequence analysis lookup (#27)#89
shinae1023 merged 1 commit into
mainfrom
feat/#27-actual-apply-count

Conversation

@shinae1023
Copy link
Copy Markdown
Member

@shinae1023 shinae1023 commented May 27, 2026

✨ 어떤 이유로 PR를 하셨나요?

  • feature 병합
  • 버그 수정(아래에 issue #를 남겨주세요)
  • 코드 개선
  • 코드 수정
  • 배포
  • 기타(아래에 자세한 내용 기입해주세요)

📋 세부 내용 - 왜 해당 PR이 필요한지 작업 내용을 자세하게 설명해주세요

📸 작업 화면 스크린샷

⚠️ PR하기 전에 확인해주세요

  • 로컬테스트를 진행하셨나요?
  • 머지할 브랜치를 확인하셨나요?
  • 관련 label을 선택하셨나요?

🚨 관련 이슈 번호 [#27]

Summary by CodeRabbit

  • New Features

    • Added new endpoint to retrieve analysis results using job posting ID and sequence number as filters.
  • Refactor

    • Simplified the primary analysis retrieval endpoint by removing the optional sequence parameter requirement.
    • Restructured the analysis service to support job posting-based analysis retrieval in addition to existing methods.

Review Change Stack

@shinae1023 shinae1023 self-assigned this May 27, 2026
@shinae1023 shinae1023 added the ✨ feat New feature or request label May 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

The PR refactors analysis retrieval from a sequence-optional path to a dual-path system: direct mockApplyId lookup and job-posting-sequence lookup. The existing AnalysisController endpoint is simplified by removing the optional sequence parameter. A new JobPostingAnalysisController exposes job-posting-based analysis retrieval. AnalysisService is updated to support both paths via a new method and updated sequence resolver using JobPostingService dependency.

Changes

Analysis Endpoint and Service Refactoring

Layer / File(s) Summary
Service infrastructure and job posting resolution
src/main/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisService.java
Adds JobPostingService dependency and imports to support job-posting-based sequence resolution. Replaces the sequence resolver helper to accept JobPosting instead of MockApply and resolves the target mock apply by iterating through user/job-posting-scoped records, with updated exception message referencing jobPostingId instead of mockApplyId.
Service methods for analysis retrieval
src/main/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisService.java
Updates getAnalysis(User, Long) implementation to load Analysis and associated QuestionAnalysis records directly by mockApplyId (throwing ANALYSIS_NOT_FOUND if absent). Adds new getAnalysisByJobPostingSequence(User, Long, int) method that resolves the owned JobPosting, finds the corresponding MockApply by sequence, loads analysis records, and returns the same AnalysisResponse shape.
Controller endpoints for analysis retrieval
src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/AnalysisController.java, src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/JobPostingAnalysisController.java
Simplifies existing AnalysisController.getAnalysis() endpoint by removing the optional sequence request parameter and updating the service call to pass only user and mockApplyId. Introduces new JobPostingAnalysisController mapped to /api/job-postings/{jobPostingId}/analysis with authenticated getAnalysisBySequence endpoint that validates authentication presence and calls the new service method.
Test updates for job-posting-based retrieval
src/test/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisServiceTest.java
Updates three test cases to validate analysisService.getAnalysisByJobPostingSequence(...) instead of the previous sequence-based retrieval method: query-based sequence selection (renamed and re-signatured), stored sequence priority (renamed and re-signatured), and non-existent sequence exception handling (updated to target job-posting-sequence API and assert MOCK_APPLY_NOT_FOUND).

Sequence Diagram

sequenceDiagram
    participant Client
    participant AnalysisController as AnalysisController<br/>(MockApply path)
    participant JobPostingAnalysisController
    participant AnalysisService
    participant JobPostingService
    
    Client->>AnalysisController: GET /api/mock-applies/{mockApplyId}/analysis
    AnalysisController->>AnalysisService: getAnalysis(user, mockApplyId)
    AnalysisService->>AnalysisService: Load Analysis + QuestionAnalysis
    AnalysisService-->>AnalysisController: AnalysisResponse
    AnalysisController-->>Client: ApiResponse<AnalysisResponse>
    
    Client->>JobPostingAnalysisController: GET /api/job-postings/{jobPostingId}/analysis?sequence=N
    JobPostingAnalysisController->>AnalysisService: getAnalysisByJobPostingSequence(user, jobPostingId, N)
    AnalysisService->>JobPostingService: Resolve JobPosting
    JobPostingService-->>AnalysisService: JobPosting entity
    AnalysisService->>AnalysisService: Resolve MockApply by sequence
    AnalysisService->>AnalysisService: Load Analysis + QuestionAnalysis
    AnalysisService-->>JobPostingAnalysisController: AnalysisResponse
    JobPostingAnalysisController-->>Client: ApiResponse<AnalysisResponse>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • JobDri-Developer/BackEnd#88: Both PRs modify AnalysisController.getAnalysis(...) and AnalysisService's handling of an optional sequence parameter (main PR removes the mockApplyId + sequence overload in favor of job-posting-sequence lookup).

  • JobDri-Developer/BackEnd#79: Both PRs directly affect the analysis sequence feature: main PR rewires analysis retrieval to a new getAnalysisByJobPostingSequence API while retrieved PR updates AnalysisResponse and AnalysisService to compute and include support sequence values in responses.

  • JobDri-Developer/BackEnd#82: Main PR refactors analysis lookup to be driven by job-posting support sequence via new AnalysisService.getAnalysisByJobPostingSequence(...) while retrieved PR persists that sequence on MockApply and updates related tests.

Poem

🐰 A rabbit's ode to dual pathways

Two roads diverge in analysis land,
One straight through mockApplyId's hand,
The other winds through jobPosting and sequence,
Each endpoint serves with graceful cadence.
Now tests validate both paths true,
A refactored journey, shiny and new! 🎯

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the template with mostly unchecked boxes and minimal completion; required sections explaining the reason, detailed work content, and pre-merge checklist items are largely unfilled. Complete the description template by: (1) checking the appropriate PR reason (feature merge), (2) providing detailed explanation of why this change is needed and what work was performed, (3) adding relevant screenshots if applicable, (4) checking the pre-merge verification checklist items.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main feature addition: implementing job posting sequence-based analysis lookup as a new capability.
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.

✏️ 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 feat/#27-actual-apply-count

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

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 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/jobdri/jobdri_api/domain/analysis/controller/AnalysisController.java`:
- Around line 40-47: The GET handler AnalysisController#getAnalysis currently
matches requests that include a legacy sequence query param and ignores it;
update the mapping to explicitly reject requests that include sequence by adding
params = "!sequence" to the `@GetMapping` on getAnalysis (e.g., `@GetMapping`(params
= "!sequence")), so requests with ?sequence=... won't match this handler and
will fail fast; keep the method signature and service call unchanged.
🪄 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 Plus

Run ID: a88e5382-00dd-4ce6-99f2-9ec0e46f3da9

📥 Commits

Reviewing files that changed from the base of the PR and between c016a96 and b468363.

📒 Files selected for processing (4)
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/AnalysisController.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/JobPostingAnalysisController.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisService.java
  • src/test/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisServiceTest.java

Comment on lines 40 to +47
@GetMapping
public ApiResponse<AnalysisResponse> getAnalysis(
@AuthenticationPrincipal UserDetailsImpl userDetails,
@PathVariable Long mockApplyId,
@RequestParam(required = false) Integer sequence
@PathVariable Long mockApplyId
) {
return ApiResponse.onSuccess(
"자소서 분석 결과 조회에 성공했습니다.",
analysisService.getAnalysis(getAuthenticatedUser(userDetails), mockApplyId, sequence)
analysisService.getAnalysis(getAuthenticatedUser(userDetails), mockApplyId)
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 | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In Spring MVC, if a controller method uses @GetMappingand does not declare@RequestParam("sequence"), does a request to the same path with ?sequence=2still match and ignore the extra query parameter by default? Also, does@GetMapping(params = "!sequence") prevent that request from matching?

💡 Result:

Yes: by default, if a controller method is mapped only with @GetMapping (matching by path and HTTP method) and it does NOT declare any request-parameter conditions via @RequestMapping(params=...) / @GetMapping(params=...), then an extra query parameter like?sequence=2 does not prevent the request from matching. Spring will still route to the handler method; @RequestParam affects only whether you can bind a specific parameter into a method argument, not whether unmapped extra query parameters block request mapping. [1][2] No: @GetMapping(params = "!sequence") does not “ignore”?sequence=2; instead it adds a request-mapping condition that requires the parameter sequence to be absent. Spring’s request-mapping “params” condition supports negation with the! form ("!myParam" means the specified parameter is not supposed to be present in the request). Therefore, a request to the same path with sequence=2 will NOT match a mapping declared with params="!sequence". [1][3][4] Example outcomes: - @GetMapping(path="/x") with no params condition: /x?sequence=2 still matches. - @GetMapping(path="/x", params="!sequence"): /x?sequence=2 does not match; only /x with no sequence parameter matches.

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the referenced controllers
ls -R src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/ 2>/dev/null || true

# Show the relevant portions of AnalysisController
sed -n '1,200p' src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/AnalysisController.java | nl -ba | sed -n '1,220p'

# Search for sequence usage in the analysis controller package
rg -n "sequence" src/main/java/com/jobdri/jobdri_api/domain/analysis/controller -S || true

# Show JobPostingAnalysisController mapping and method(s) mentioning sequence
sed -n '1,240p' src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/JobPostingAnalysisController.java | nl -ba | sed -n '1,260p'

Repository: JobDri-Developer/BackEnd

Length of output: 276


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show relevant parts of AnalysisController
sed -n '1,220p' src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/AnalysisController.java

# Search for "sequence" usage in the analysis controller package
rg -n "sequence" src/main/java/com/jobdri/jobdri_api/domain/analysis/controller -S || true

# Show relevant parts of JobPostingAnalysisController
sed -n '1,260p' src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/JobPostingAnalysisController.java

Repository: JobDri-Developer/BackEnd

Length of output: 5211


Reject legacy sequence query param on /api/mock-applies/{mockApplyId}/analysis GET to avoid silent wrong results

AnalysisController#getAnalysis maps GET /api/mock-applies/{mockApplyId}/analysis with @GetMapping but does not declare a sequence request parameter (no @RequestParam("sequence") and no params condition). A request to /api/mock-applies/{mockApplyId}/analysis?sequence=N will still match this handler, and sequence will be ignored, returning results based only on mockApplyId—silently breaking the expected “sequence-based” behavior clients may be using.

GET /api/job-postings/{jobPostingId}/analysis?sequence=N

exists in JobPostingAnalysisController, so fail fast on the legacy route by rejecting requests that include sequence.

🧭 Minimal guard to fail fast on legacy `sequence` calls
-    `@GetMapping`
+    `@GetMapping`(params = "!sequence")
     public ApiResponse<AnalysisResponse> getAnalysis(
             `@AuthenticationPrincipal` UserDetailsImpl userDetails,
             `@PathVariable` Long mockApplyId
     ) {
🤖 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/analysis/controller/AnalysisController.java`
around lines 40 - 47, The GET handler AnalysisController#getAnalysis currently
matches requests that include a legacy sequence query param and ignores it;
update the mapping to explicitly reject requests that include sequence by adding
params = "!sequence" to the `@GetMapping` on getAnalysis (e.g., `@GetMapping`(params
= "!sequence")), so requests with ?sequence=... won't match this handler and
will fail fast; keep the method signature and service call unchanged.

@shinae1023 shinae1023 merged commit 25c71d6 into main May 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feat New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant