Skip to content

[FEAT] 분석 결과 및 상태 조회 API 구현 - #44

Merged
ownue merged 14 commits into
developfrom
feat/#26-analysis-result
Jul 25, 2026
Merged

[FEAT] 분석 결과 및 상태 조회 API 구현#44
ownue merged 14 commits into
developfrom
feat/#26-analysis-result

Conversation

@ownue

@ownue ownue commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

📍 개요

분석 결과 및 상태 조회 API 구현

⛓️‍💥 관련 이슈


🛠️ 작업 내용

  • 분석 결과 조회 API 구현
  • 분석 상태 조회 API 구현
  • 컨트롤러 단위 테스트 추가
  • docker-compose.local.yml PostgreSQL 16 → 18로 버전 및 볼륨 경로 수정
  • src/main/resources/application.yml, application.example.yml을 git 추적에서 제거

🔥 리뷰 요청 사항

리뷰어가 중점적으로 확인해주었으면 하는 내용을 작성해주세요.

  • 로직이 적절한지
  • application.yml 관련 파일 git 추적 제거 및 .gitignore 변경 방향이 맞는지

✅ 체크리스트

  • 코드 컨벤션을 준수했습니다.
  • 불필요한 코드 및 import를 제거했습니다.
  • 예외 처리를 적용했습니다.
  • 테스트를 완료했습니다.
  • 관련 Issue를 연결했습니다.

📎 참고 사항

  • 컨벤션에 맞지 않게 와일드 카드 사용한 곳이 있다면 다음 주에 한 번에 수정하겠습니당...^_^

Summary by CodeRabbit

  • 새 기능
    • 분석 진행 상태 조회와 완료된 분석 결과(점수·등급·리포트) 확인 API를 추가했습니다.
    • 접근 권한/존재 여부/미완료 상황에 대한 표준 오류 응답을 제공합니다.
  • 개선
    • 로컬 예시 설정을 환경 변수 템플릿 형태로 정비하고, 업로드 파일/요청 용량 제한(각 20MB)을 추가했습니다.
    • 로컬 PostgreSQL 이미지를 18로 업데이트하고, 비밀이 포함될 수 있는 로컬 설정 파일은 무시하도록 처리했습니다.
  • 테스트
    • 분석 상태·결과 조회 및 주요 오류 응답에 대한 테스트를 추가했습니다.

@ownue ownue self-assigned this Jul 24, 2026
@ownue ownue added the ✨feat label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

분석 상태·결과 조회 API, 응답 DTO, 저장소, 서비스, 오류 처리가 추가되었습니다. 관련 컨트롤러·서비스 테스트가 성공 및 예외 응답을 검증하며, 로컬 설정은 환경변수 기반으로 전환되고 PostgreSQL 구성이 업데이트되었습니다.

Changes

분석 조회 API

Layer / File(s) Summary
분석 조회 계약과 저장소
src/main/java/com/mr/domain/analysis/dto/res/*, src/main/java/com/mr/domain/analysis/exception/AnalysisErrorStatus.java, src/main/java/com/mr/domain/analysis/repository/*, src/main/java/com/mr/domain/analysis/entity/AnalysisReport.java
상태·결과 응답 DTO, 분석 오류 코드, 분석·리포트 저장소 조회 메서드 및 리포트 일대일 매핑이 추가되었습니다.
분석 조회 서비스 흐름
src/main/java/com/mr/domain/analysis/service/AnalysisService.java
분석 소유자와 완료 상태를 검증하고, 상태별 진행률·메시지 및 최신 성공 리포트·원본 JSON을 응답 DTO로 변환합니다.
조회 API 연결과 검증
src/main/java/com/mr/domain/analysis/controller/AnalysisController.java, src/test/java/com/mr/domain/analysis/controller/AnalysisControllerTest.java
상태·결과 GET 엔드포인트를 추가하고 성공, 미존재, 접근 거부, 미완료 오류 응답을 검증합니다.
분석 결과 서비스 검증
src/test/java/com/mr/domain/analysis/service/AnalysisServiceTest.java
SUCCESS 리포트 매핑과 SUCCESS 리포트 부재 시 null 리포트 반환을 검증합니다.

로컬 환경 설정

Layer / File(s) Summary
로컬 설정 및 데이터베이스 구성
.gitignore, MR_config/local/application.example.yml, docker-compose.local.yml, src/main/resources/application*.yml
환경변수 기반 설정, 업로드 제한, 외부 연동·AWS 설정을 추가하고 설정 산출물 무시 규칙을 변경했습니다. PostgreSQL 이미지는 18로 변경되며 볼륨 경로도 조정되었습니다.

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 성공 응답 반환
Loading

Possibly related PRs

  • Musereview/BE#7: AnalysisReport 및 분석 조회 구성요소를 기반으로 확장한 변경입니다.
  • Musereview/BE#11: 동일한 로컬 PostgreSQL Docker Compose 구성을 다룹니다.

Poem

상태는 폴링, 결과는 찰칵
점수와 리포트 한 바구니에 착
비밀값은 환경변수 뒤로 숨고
Postgres는 열여덟으로 뛰고
API 여정, 오늘도 순항! 🚢

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning PostgreSQL 버전 변경, 설정 파일 추적 제거, .gitignore 수정은 이슈 #26의 API 구현 범위를 벗어난 변경입니다. 인프라·설정 정리는 별도 PR로 분리하고, 이번 PR에는 분석 상태/결과 조회 기능 관련 코드만 남기세요.
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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 분석 결과·상태 조회 API 구현이라는 핵심 변경을 간결하게 잘 요약합니다.
Linked Issues check ✅ Passed 상태/결과 DTO, 컨트롤러, 리포지토리, 권한 검증, 예외 처리와 테스트가 이슈 #26 요구사항을 충족합니다.
✨ 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/#26-analysis-result

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

PostgreSQL 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

📥 Commits

Reviewing files that changed from the base of the PR and between 274468e and 4eef1e7.

📒 Files selected for processing (13)
  • .gitignore
  • MR_config/local/application.example.yml
  • docker-compose.local.yml
  • src/main/java/com/mr/domain/analysis/controller/AnalysisController.java
  • src/main/java/com/mr/domain/analysis/dto/res/AnalysisResultResponseDTO.java
  • src/main/java/com/mr/domain/analysis/dto/res/AnalysisStatusResponseDTO.java
  • src/main/java/com/mr/domain/analysis/exception/AnalysisErrorStatus.java
  • src/main/java/com/mr/domain/analysis/repository/AnalysisReportRepository.java
  • src/main/java/com/mr/domain/analysis/repository/AnalysisRepository.java
  • src/main/java/com/mr/domain/analysis/service/AnalysisService.java
  • src/main/resources/application.example.yml
  • src/main/resources/application.yml
  • src/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

Comment thread src/main/java/com/mr/domain/analysis/controller/AnalysisController.java Outdated

@p1001q p1001q left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨어요!!

Comment thread MR_config/local/application.example.yml

public interface AnalysisReportRepository extends JpaRepository<AnalysisReport, Long> {

Optional<AnalysisReport> findFirstByAnalysisIdOrderByCreatedAtDesc(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: 현재는 생성 시각을 기준으로 가장 최근의 리포트를 조회하고 있는데, AnalysisReport에 llmStatus가 존재해서 최신 리포트가 실패하거나 처리 중인 상태일 경우도 고려해야 할 것 같습니다~
결과 조회 API에서 가장 최근에 정상 생성된 리포트를 반환하려는 정책이라면 LlmStatus.SUCCESS 조건도 함께 적용하는 건 어떨까요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

하나의 분석에 여러 개의 리포트가 저장될 필요가 없는 것 같아 OneToOne 관계로 바꾸고, 최근 정상 생성이 아닌, 정상 생성된 리포트를 반환하도록 수정하겠습니다!

실패 혹은 처리 중인 관계는 (1) 프론트에서 status polling 후 LlmStatus.SUCCESS 일 때 (2) 해당 API 호출로 생각하여 누락시켰던 것 같습니다! 꼼꼼히 예외 상황을 처리할 필요가 있을 것 같은데, 이 부분은 서브 이슈로 파서 리팩토링 하도록 하겠습니다~!


public interface AnalysisRepository extends JpaRepository<Analysis, Long> {

Optional<Analysis> findByIdAndUserId(Long analysisId, Long userId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: 미사용 Repository 메서드 (findByIdAndUserId) 정리 제안

현재 AnalysisService에서는 **findById()로 우선 조회 → validateOwner()**를 통해 소유권을 검증하여 403 ACCESS_DENIED 보내는 로직이 맞을까요?

만약 findByIdAndUserId()를 쓰면 데이터가 없을 때 404 NOT_FOUND가 나가는데, 현재처럼 403을 응답하는 권한 정책을 유지한다면 findByIdAndUserId 메서드는 사용되지 않는 데드 코드가 되는 것 같아 여쭙니다

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findById() + validateOwner()로 403/404를 분리하는 게 목적이었어서, 불필요한 코드인 findByIdAndUserId() 삭제 처리하겠습니다! 감사합니다~!

@on1yoneprivate on1yoneprivate left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다
몇 가지 논의할 부분이 있어 코멘트 남겼으니, 확인해 주세요~

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/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

📥 Commits

Reviewing files that changed from the base of the PR and between 4eef1e7 and e73b6cc.

📒 Files selected for processing (7)
  • src/main/java/com/mr/domain/analysis/controller/AnalysisController.java
  • src/main/java/com/mr/domain/analysis/entity/AnalysisReport.java
  • src/main/java/com/mr/domain/analysis/repository/AnalysisReportRepository.java
  • src/main/java/com/mr/domain/analysis/repository/AnalysisRepository.java
  • src/main/java/com/mr/domain/analysis/service/AnalysisService.java
  • src/test/java/com/mr/domain/analysis/controller/AnalysisControllerTest.java
  • src/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

Comment thread src/main/java/com/mr/domain/analysis/entity/AnalysisReport.java
@ownue
ownue merged commit c78a2c3 into develop Jul 25, 2026
2 checks passed
@ownue
ownue deleted the feat/#26-analysis-result branch July 25, 2026 08:09
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.

✨ Feature - 분석 상태 및 결과 조회 API 구현

3 participants