[FEAT] 분석 결과 및 상태 조회 API 구현 - #44
Conversation
📝 WalkthroughWalkthrough분석 상태·결과 조회 API, 응답 DTO, 저장소, 서비스, 오류 처리가 추가되었습니다. 관련 컨트롤러·서비스 테스트가 성공 및 예외 응답을 검증하며, 로컬 설정은 환경변수 기반으로 전환되고 PostgreSQL 구성이 업데이트되었습니다. Changes분석 조회 API
로컬 환경 설정
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant AnalysisController
participant AnalysisService
participant AnalysisRepository
participant AnalysisReportRepository
Client->>AnalysisController: 분석 결과 GET 요청
AnalysisController->>AnalysisService: 사용자 ID와 analysisId 전달
AnalysisService->>AnalysisRepository: 분석 조회
AnalysisService->>AnalysisReportRepository: 최신 SUCCESS 리포트 조회
AnalysisService-->>AnalysisController: 결과 DTO 반환
AnalysisController-->>Client: ApiResponse 성공 응답 반환
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docker-compose.local.yml (1)
3-12: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPostgreSQL 18 마이그레이션 설명을 추가하세요.
mysqlereview-postgres-data볼륨에 기존 PostgreSQL 16 클러스터가 있으면postgres:18은/var/lib/postgresql/18/docker경로를 기본PGDATA로 사용하므로, 같은 볼륨 공유만으로는 데이터가 인식되지 않습니다. 기존 개발 환경을 위해pg_dump/복원이나pg_upgrade절차를 README/환경 설정 문서에 남기거나 18 전용 볼륨을 사용하세요. 공식 Docker PostgreSQL 18 문서도 버전별PGDATA구조와 기존 데이터 마이그레이션을 안내합니다.🤖 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 `@docker-compose.local.yml` around lines 3 - 12, Update the PostgreSQL 18 setup around the musereview-postgres-data volume to document the required migration path for existing PostgreSQL 16 clusters, using pg_dump/restore or pg_upgrade, or switch to a dedicated PostgreSQL 18 volume. Ensure the configuration does not imply that reusing the existing volume alone will discover the old data under PostgreSQL 18’s versioned PGDATA layout.
🤖 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/mr/domain/analysis/controller/AnalysisController.java`:
- Around line 18-42: Replace the hardcoded TEMP_USER_ID usage in
AnalysisController.getAnalysisStatus and getAnalysisResult with the
authenticated requester ID from SecurityUtil or the established security
context, and pass that ID to both analysisService calls. Update related tests to
assert the authenticated ID is forwarded rather than matching anyLong().
---
Outside diff comments:
In `@docker-compose.local.yml`:
- Around line 3-12: Update the PostgreSQL 18 setup around the
musereview-postgres-data volume to document the required migration path for
existing PostgreSQL 16 clusters, using pg_dump/restore or pg_upgrade, or switch
to a dedicated PostgreSQL 18 volume. Ensure the configuration does not imply
that reusing the existing volume alone will discover the old data under
PostgreSQL 18’s versioned PGDATA layout.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9dd611d9-7f47-4edc-a6e6-f812cae3eb46
📒 Files selected for processing (13)
.gitignoreMR_config/local/application.example.ymldocker-compose.local.ymlsrc/main/java/com/mr/domain/analysis/controller/AnalysisController.javasrc/main/java/com/mr/domain/analysis/dto/res/AnalysisResultResponseDTO.javasrc/main/java/com/mr/domain/analysis/dto/res/AnalysisStatusResponseDTO.javasrc/main/java/com/mr/domain/analysis/exception/AnalysisErrorStatus.javasrc/main/java/com/mr/domain/analysis/repository/AnalysisReportRepository.javasrc/main/java/com/mr/domain/analysis/repository/AnalysisRepository.javasrc/main/java/com/mr/domain/analysis/service/AnalysisService.javasrc/main/resources/application.example.ymlsrc/main/resources/application.ymlsrc/test/java/com/mr/domain/analysis/controller/AnalysisControllerTest.java
💤 Files with no reviewable changes (2)
- src/main/resources/application.example.yml
- src/main/resources/application.yml
|
|
||
| public interface AnalysisReportRepository extends JpaRepository<AnalysisReport, Long> { | ||
|
|
||
| Optional<AnalysisReport> findFirstByAnalysisIdOrderByCreatedAtDesc( |
There was a problem hiding this comment.
P2: 현재는 생성 시각을 기준으로 가장 최근의 리포트를 조회하고 있는데, AnalysisReport에 llmStatus가 존재해서 최신 리포트가 실패하거나 처리 중인 상태일 경우도 고려해야 할 것 같습니다~
결과 조회 API에서 가장 최근에 정상 생성된 리포트를 반환하려는 정책이라면 LlmStatus.SUCCESS 조건도 함께 적용하는 건 어떨까요?
There was a problem hiding this comment.
하나의 분석에 여러 개의 리포트가 저장될 필요가 없는 것 같아 OneToOne 관계로 바꾸고, 최근 정상 생성이 아닌, 정상 생성된 리포트를 반환하도록 수정하겠습니다!
실패 혹은 처리 중인 관계는 (1) 프론트에서 status polling 후 LlmStatus.SUCCESS 일 때 (2) 해당 API 호출로 생각하여 누락시켰던 것 같습니다! 꼼꼼히 예외 상황을 처리할 필요가 있을 것 같은데, 이 부분은 서브 이슈로 파서 리팩토링 하도록 하겠습니다~!
|
|
||
| public interface AnalysisRepository extends JpaRepository<Analysis, Long> { | ||
|
|
||
| Optional<Analysis> findByIdAndUserId(Long analysisId, Long userId); |
There was a problem hiding this comment.
P3: 미사용 Repository 메서드 (findByIdAndUserId) 정리 제안
현재 AnalysisService에서는 **findById()로 우선 조회 → validateOwner()**를 통해 소유권을 검증하여 403 ACCESS_DENIED 보내는 로직이 맞을까요?
만약 findByIdAndUserId()를 쓰면 데이터가 없을 때 404 NOT_FOUND가 나가는데, 현재처럼 403을 응답하는 권한 정책을 유지한다면 findByIdAndUserId 메서드는 사용되지 않는 데드 코드가 되는 것 같아 여쭙니다
There was a problem hiding this comment.
findById() + validateOwner()로 403/404를 분리하는 게 목적이었어서, 불필요한 코드인 findByIdAndUserId() 삭제 처리하겠습니다! 감사합니다~!
on1yoneprivate
left a comment
There was a problem hiding this 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/mr/domain/analysis/entity/AnalysisReport.java`:
- Around line 23-24: Update the migration setup associated with AnalysisReport
so the analysis_reports.analysis_id UNIQUE constraint is applied in the
database, not only via `@JoinColumn`. Add a migration/backfill script that removes
duplicate reports per analysis_id while preserving the latest SUCCESS report,
then create the unique constraint after cleanup and ensure the migration is safe
for existing data.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d6f082d6-13c8-402e-ac04-7d036cc98582
📒 Files selected for processing (7)
src/main/java/com/mr/domain/analysis/controller/AnalysisController.javasrc/main/java/com/mr/domain/analysis/entity/AnalysisReport.javasrc/main/java/com/mr/domain/analysis/repository/AnalysisReportRepository.javasrc/main/java/com/mr/domain/analysis/repository/AnalysisRepository.javasrc/main/java/com/mr/domain/analysis/service/AnalysisService.javasrc/test/java/com/mr/domain/analysis/controller/AnalysisControllerTest.javasrc/test/java/com/mr/domain/analysis/service/AnalysisServiceTest.java
💤 Files with no reviewable changes (1)
- src/main/java/com/mr/domain/analysis/repository/AnalysisRepository.java
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/java/com/mr/domain/analysis/service/AnalysisService.java
- src/test/java/com/mr/domain/analysis/controller/AnalysisControllerTest.java
📍 개요
⛓️💥 관련 이슈
🛠️ 작업 내용
docker-compose.local.ymlPostgreSQL 16 → 18로 버전 및 볼륨 경로 수정src/main/resources/application.yml,application.example.yml을 git 추적에서 제거🔥 리뷰 요청 사항
application.yml관련 파일 git 추적 제거 및.gitignore변경 방향이 맞는지✅ 체크리스트
📎 참고 사항
Summary by CodeRabbit