[Fix] 모집 예정 공고 조회 시 일정 데이터 미반환 문제 수정#167
Conversation
- findCurrentOrUpcoming 쿼리 추가: endDate 미경과 공고 중 startDate 가장 임박한 것 반환 - getRecruitmentStatus: 예정 공고 존재 시 is_active:false여도 term 반환 - getRecruitment: is_active 여부와 무관하게 모든 필드 반환
📝 Walkthrough📋 전체 요약모집 공고 조회 흐름을 "활성 모집만" → "현재 또는 예정 모집"으로 개선했습니다. 저장소에 새로운 쿼리 메서드를 추가하고, 서비스에서 이를 활용하여 isActive 판정을 개선하며, 테스트 커버리지를 예정 공고까지 확장했습니다. 🔄 주요 변경 사항모집 공고 조회 개선
🎯 4 (Complex) | ⏱️ ~35분 🚥 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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/com/boaz/backend/domain/recruitment/repository/RecruitmentRepository.java (1)
17-19: JPQLLIMIT호환성 우려: 현재(Spring Boot 3.4.3)에서는 리스크가 낮습니다.
build.gradle에org.springframework.boot3.4.3이 지정돼 있어(= Hibernate 6 계열)@Query의LIMIT 1문법이 런타임에서 깨질 가능성은 낮습니다.
다만 더 표준/이식성을 원하면Pageable또는fetch first 1 row only같은 방식으로 바꾸는 건 선택사항입니다.🤖 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/boaz/backend/domain/recruitment/repository/RecruitmentRepository.java` around lines 17 - 19, The JPQL query in RecruitmentRepository (method findCurrentOrUpcoming) uses a non-standard "LIMIT 1"; update it for compatibility by removing "LIMIT 1" and either (a) change the repository method to accept a Pageable (e.g., PageRequest.of(0,1)) and return Optional/List/Stream accordingly while keeping "ORDER BY r.startDate ASC" in the `@Query`, or (b) replace the `@Query` with a native SQL using "fetch first 1 row only" and set nativeQuery=true; adjust the method signature and call sites to use the chosen approach so only one result is returned reliably across JPA providers.
🤖 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.
Nitpick comments:
In
`@src/main/java/com/boaz/backend/domain/recruitment/repository/RecruitmentRepository.java`:
- Around line 17-19: The JPQL query in RecruitmentRepository (method
findCurrentOrUpcoming) uses a non-standard "LIMIT 1"; update it for
compatibility by removing "LIMIT 1" and either (a) change the repository method
to accept a Pageable (e.g., PageRequest.of(0,1)) and return Optional/List/Stream
accordingly while keeping "ORDER BY r.startDate ASC" in the `@Query`, or (b)
replace the `@Query` with a native SQL using "fetch first 1 row only" and set
nativeQuery=true; adjust the method signature and call sites to use the chosen
approach so only one result is returned reliably across JPA providers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0a76cc16-054f-471c-bfe9-9a91ae2090fa
📒 Files selected for processing (3)
src/main/java/com/boaz/backend/domain/recruitment/repository/RecruitmentRepository.javasrc/main/java/com/boaz/backend/domain/recruitment/service/RecruitmentService.javasrc/test/java/com/boaz/backend/domain/recruitment/service/RecruitmentServiceTest.java
💡 개요
🪐 주요 변경 사항
findCurrentOrUpcoming쿼리 추가 — endDate 미경과 공고 중 startDate 가장 임박한 것 반환 (모집 중 + 예정 공고 모두 포함)getRecruitmentStatus: 예정 공고 존재 시is_active: false여도term반환getRecruitment:is_active여부와 무관하게start_date,end_date,schedule,brochure_url등 모든 필드 반환 (brochure_url은 미등록 시 null)✅ 상세 내용
findActiveRecruitment는 모집 중인 공고만 잡아 예정 공고의 term을/status에서 내려줄 수 없었음findCurrentOrUpcoming은endDate >= now조건으로 모집 중 + 예정을 함께 조회하고,r.isActive(now)로is_active값을 정확히 계산RecruitmentResponse.from(recruitment, isActive)생성자는is_active: false일 때 날짜/일정 필드를 null로 덮어쓰는 문제가 있어,from(recruitment, now())생성자로 교체🔔 참고 사항
term없음 → 섹션 미렌더 /term있고is_active: false→ 시작일까지 D-day + 사전알림 /term있고is_active: true→ 마감일까지 카운트다운변경 목적
모집 예정 공고 조회 시 일정 데이터가 반환되지 않는 문제를 해결하기 위해, 리포지토리 쿼리를 추가하고 서비스 로직을 개선하여 활성 공고뿐만 아니라 예정 공고도 함께 조회하고 일정 정보를 정상 반환하도록 수정했습니다.
주요 변경 내용
Repository 레이어
findCurrentOrUpcoming(LocalDateTime now)메서드 추가: endDate가 현재 이후인 공고 중 startDate가 가장 임박한 공고 1건 조회 (활성 + 예정 공고 포함)Service 레이어
getRecruitmentStatus(): 기존 활성 모집만 조회하던 방식에서 현재/예정 공고 조회로 변경; 예정 공고 존재 시에도 일정(term) 정보 반환getRecruitment():is_active값과 무관하게start_date,end_date,schedule,brochure_url등 모든 날짜/일정 필드 반환Test 레이어
findActiveRecruitment()에서findCurrentOrUpcoming()으로 변경is_active:false) 케이스에 대한 테스트 커버리지 확충영향 범위
/status엔드포인트가 예정 공고의 일정(term) 정보를 추가로 반환