Skip to content

[Fix] 재지원 공고 연결 기준 수정#90

Merged
whc9999 merged 2 commits into
mainfrom
fix/#38-mock-apply-retry
May 27, 2026
Merged

[Fix] 재지원 공고 연결 기준 수정#90
whc9999 merged 2 commits into
mainfrom
fix/#38-mock-apply-retry

Conversation

@whc9999
Copy link
Copy Markdown
Collaborator

@whc9999 whc9999 commented May 27, 2026

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

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

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

  • 재지원 시 새 JobPosting을 복제 생성하지 않고 원본 공고에 새 MockApply만 생성
  • MockApply sequence 자동 할당 기준을 user + jobPostingId로 변경
  • 같은 회사/직무의 다른 공고는 각각 독립된 sequence를 갖도록 테스트 수정
  • 재지원 시 같은 jobPostingId 안에서 sequence가 증가하는지 검증

📸 작업 화면 스크린샷

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

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

🚨 관련 이슈 번호 [#38 ]

Summary by CodeRabbit

  • Bug Fixes

    • Refined sequence numbering for mock application retries to avoid conflicts.
  • Refactor

    • Sequence tracking key changed to be scoped by job posting rather than broader classification.
  • Tests

    • Updated unit tests to reflect new sequence and retry behaviors.
  • Documentation

    • Cleaned up API documentation for the mock application retry endpoint.

Review Change Stack

- 재지원 시 새 JobPosting을 복제 생성하지 않고 원본 공고에 새 MockApply만 생성
- MockApply sequence 자동 할당 기준을 user + jobPostingId로 변경
- 같은 회사/직무의 다른 공고는 각각 독립된 sequence를 갖도록 테스트 수정
- 재지원 시 같은 jobPostingId 안에서 sequence가 증가하는지 검증
@whc9999 whc9999 self-assigned this May 27, 2026
@whc9999 whc9999 added the fix label May 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

Re-keys mock-apply sequence allocation from (companyId, detailClassificationId) to jobPostingId: update entity constraint, repository queries, sequence allocation service and MockApplyService retry flow, adjust tests, and remove a trailing suffix from the retry endpoint OpenAPI summary.

Changes

MockApply Sequence Allocation Refactoring

Layer / File(s) Summary
MockApplySequence entity key & factory update
src/main/java/com/jobdri/jobdri_api/domain/mockapply/entity/MockApplySequence.java
Unique constraint and entity fields changed to use jobPostingId; factory create(...) signature updated to accept jobPostingId.
MockApplyRepository max-sequence finder
src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.java
Replaced prior max-sequence finder with findMaxSequenceByUserIdAndJobPostingId(...) querying ma.user.id and ma.jobPosting.id.
MockApplySequenceRepository key-for-update query
src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplySequenceRepository.java
findByKeyForUpdate now locks/looks up by userId and jobPostingId (param bindings updated).
MockApplySequenceService allocate by jobPostingId
src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplySequenceService.java
allocate(userId, jobPostingId) fetches/creates sequence row keyed by jobPostingId, using findMaxSequenceByUserIdAndJobPostingId(...) for initial value and then increments.
MockApplyService retry & allocation callsite
src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
retryMockApply now reuses original sourceJobPosting instead of persisting a clone; allocateSequence retries on constraint violations but calls allocate with jobPostingId.
Tests: sequence and retry expectations
src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java
Adjusts test expectations: second apply sequence for same company/different job postings becomes 1; retry test asserts retry references same jobPosting and expected sequence/status/applyType.
OpenAPI doc cleanup
src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java
Removed trailing " - " from the retry endpoint @Operation.summary string.

Sequence Diagram

sequenceDiagram
  participant Client
  participant MockApplyService
  participant MockApplySequenceService
  participant MockApplySequenceRepository
  participant MockApplyRepository
  participant Database

  Client->>MockApplyService: retryMockApply(request)
  MockApplyService->>MockApplySequenceService: allocate(userId, jobPostingId)
  MockApplySequenceService->>MockApplySequenceRepository: findByKeyForUpdate(userId, jobPostingId)
  MockApplySequenceRepository->>Database: SELECT ... FOR UPDATE (mas where userId & jobPostingId)
  MockApplySequenceService->>MockApplyRepository: findMaxSequenceByUserIdAndJobPostingId(userId, jobPostingId)
  MockApplyRepository->>Database: SELECT coalesce(max(sequence),0) FROM mock_apply WHERE user_id=? AND job_posting_id=?
  MockApplyService->>MockApplyRepository: saveMockApplyWithSequence(mockApply with allocated sequence)
  MockApplyRepository->>Database: INSERT/UPDATE mock_apply / mock_apply_sequence rows
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • shinae1023

Poem

🐰 I hopped through tables, keys, and rows,
Swapped two IDs for one that knows.
No clone, no fuss — just reuse the post,
Sequence finds its place the most.
🥕 Hop happy, code well-roasted!

🚥 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 The title clearly and specifically describes the main change: fixing the connection criteria for retry applications from (company, detailClassification) to (jobPosting).
Description check ✅ Passed The description follows the template structure, includes completed sections with clear explanations of changes, confirms local testing and branch verification, and references the related issue.
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 fix/#38-mock-apply-retry

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

🤖 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/mockapply/controller/MockApplyController.java`:
- Line 203: Update the OpenAPI description string in MockApplyController (the
description used in the `@Operation` annotation for the retry endpoint) to reflect
that the new retry creates a new MockApply linked to the original JobPosting
rather than copying the posting and selection questions; change wording from
"복사" (copy) to indicate "재사용" or "원본 공고와 연동" and that answers are cleared so the
applicant restarts from the essay input step.

In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java`:
- Around line 259-262: The current max+1 allocation in MockApplyService (using
mockApplyRepository.findMaxSequenceByUserIdAndJobPostingId) races under
concurrent creates for the same (user, jobPosting); replace it with a
serialized, DB-backed counter or lock: create or use a dedicated counter row
keyed by (userId, jobPostingId) and SELECT ... FOR UPDATE (or a JPA/Pessimistic
WRITE lock) to increment and return the next sequence inside the same
transaction, or alternatively use a database sequence/atomic counter scoped to
that key; ensure the allocation logic in MockApplyService obtains the
lock/counter, increments it in-transaction, and then uses that value for the new
mock apply instead of computing max+1.
🪄 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: 6712b845-5d9c-46a7-aad9-2d24665bc10c

📥 Commits

Reviewing files that changed from the base of the PR and between 25c71d6 and 8645fd8.

📒 Files selected for processing (4)
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
  • src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java

@Operation(
summary = "모의 서류 지원 재도전 - ",
summary = "모의 서류 지원 재도전",
description = "기존 모의 서류 지원의 공고와 선택 문항을 복사해 새 회차의 모의 서류 지원을 생성합니다. 답변은 비워진 상태로 자소서 입력 단계부터 다시 진행합니다."
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 | 🟡 Minor | ⚡ Quick win

OpenAPI description is stale vs new retry behavior.

Line 203 still says the retry flow “copies” the posting, but this PR’s behavior is to create a new MockApply linked to the original JobPosting. Please update the description text to reflect reuse of the original posting.

🤖 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/mockapply/controller/MockApplyController.java`
at line 203, Update the OpenAPI description string in MockApplyController (the
description used in the `@Operation` annotation for the retry endpoint) to reflect
that the new retry creates a new MockApply linked to the original JobPosting
rather than copying the posting and selection questions; change wording from
"복사" (copy) to indicate "재사용" or "원본 공고와 연동" and that answers are cleared so the
applicant restarts from the essay input step.

- MockApplySequence 키를 userId + jobPostingId 기준으로 변경
- sequence 할당 시 PESSIMISTIC_WRITE 락으로 카운터 row 직렬화
- MockApplyService의 max+1 직접 계산 제거
- 카운터 생성 충돌 시 재시도 후 GeneralException으로 매핑
- 재지원 시 같은 공고 내 sequence가 안정적으로 증가하도록 보완
@whc9999 whc9999 merged commit fc22b46 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant