[Fix] 재지원 순번 계산 기준 수정#84
Conversation
- 자동 sequence 계산 기준을 공고 ID에서 사용자, 회사, 직무 기준으로 변경 - 재지원 시 공고가 복제되어도 같은 회사와 직무이면 다음 순번이 저장되도록 수정 - 같은 회사와 직무의 다른 공고로 재지원할 때 sequence가 증가하는 테스트 추가 - 기존 명시 sequence 저장 및 중복 충돌 처리 로직은 유지
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughSequence allocation is refactored from per-job-posting to per-(user,company,detailClassification): new MockApplySequence entity and repo, allocator service (REQUIRES_NEW + pessimistic lock), a repo query for initial max, service retry wiring, and tests validating cross-posting increments. ChangesMock Application Sequence Scope
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
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.
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/mockapply/service/MockApplyService.java`:
- Around line 204-208: The current max+1 allocation in MockApplyService is racy;
replace it with an atomic sequence lookup/increment keyed by (user_id,
company_id, detail_classification_id). Add a dedicated sequence
entity/repository (e.g., MockApplySequence) with a method like
findByKeyForUpdate or incrementAndGet that runs inside a `@Transactional` method
using a row lock (SELECT ... FOR UPDATE) or PESSIMISTIC_WRITE lock to
insert-if-missing then increment the counter, and call that method from
MockApplyService instead of
mockApplyRepository.findMaxSequenceByUserIdAndCompanyIdAndDetailClassificationId(...)+1;
ensure the new allocation method is transactional so concurrent requests
serialize on the sequence row (alternatively implement DB-enforced unique
constraint + retry loop if insert fails).
🪄 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: 17a51003-b560-4708-a6f2-12b983e930ac
📒 Files selected for processing (3)
src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.javasrc/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.javasrc/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java
- 사용자, 회사, 직무 기준 순번 관리를 위한 MockApplySequence 엔티티 추가 - 순번 row를 비관적 락으로 조회한 뒤 증가시키는 전용 서비스 추가 - 자동 sequence 생성 시 max+1 직접 계산 대신 원자적 allocator를 사용하도록 수정 - sequence row 최초 생성 시 기존 모의 서류 지원의 최대 순번을 기준으로 초기화 - 최초 row 생성 충돌 시 재시도하도록 처리
There was a problem hiding this comment.
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/mockapply/service/MockApplyService.java`:
- Around line 217-227: The catch currently rethrows
DataIntegrityViolationException on the final attempt which bypasses the intended
mapping to GeneralException; in MockApplyService (the loop that uses
SEQUENCE_ALLOCATE_MAX_RETRY) stop rethrowing inside the catch and instead either
let the loop exit or throw the GeneralException there — e.g., replace "if
(attempt == SEQUENCE_ALLOCATE_MAX_RETRY - 1) { throw e; }" with logic that does
not rethrow (or directly throws new
GeneralException(GeneralErrorCode.INTERNAL_SERVER_ERROR, "모의 서류 지원 순번 할당에
실패했습니다.")) so the DataIntegrityViolationException no longer bypasses the
GeneralException path.
🪄 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: 2bc72c06-8166-4b86-803f-bcf57619bd62
📒 Files selected for processing (4)
src/main/java/com/jobdri/jobdri_api/domain/mockapply/entity/MockApplySequence.javasrc/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplySequenceRepository.javasrc/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplySequenceService.javasrc/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
- sequence row 생성 재시도 최종 실패 시 DataIntegrityViolationException이 그대로 전파되지 않도록 수정 - 순번 할당 실패를 기존 정책에 맞춰 INTERNAL_SERVER_ERROR GeneralException으로 변환 - 모의 서류 지원 생성 경로의 예외 응답 일관성 보강
✨ 어떤 이유로 PR를 하셨나요?
📋 세부 내용 - 왜 해당 PR이 필요한지 작업 내용을 자세하게 설명해주세요
📸 작업 화면 스크린샷
🚨 관련 이슈 번호 []
Summary by CodeRabbit
New Features
Tests