Skip to content

[FEAT] 분석 상태 조회 API 구현#37

Merged
dldusgh318 merged 2 commits into
SeCause:developfrom
dldusgh318:develop
Jun 14, 2026
Merged

[FEAT] 분석 상태 조회 API 구현#37
dldusgh318 merged 2 commits into
SeCause:developfrom
dldusgh318:develop

Conversation

@dldusgh318

@dldusgh318 dldusgh318 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

‼️ 관련 이슈

close #32


🔎 개요

분석 요청 생성 이후 프론트에서 폴링으로 분석 진행 상태를 조회할 수 있도록 분석 상태 조회 API를 구현했습니다.


📝 작업 내용

  • GET /api/analysis/request/{analysisId}/status API 추가
  • 분석 요청 생성 시 반환되는 analysisId를 기준으로 상태 조회하도록 구현
  • analyses 테이블의 분석 상태, 진행률, 실패 사유 반환
  • 로그인한 사용자의 분석 요청만 조회 가능하도록 권한 검증 추가
  • 분석 결과가 없거나 본인 소유가 아닌 경우 404 응답 처리
  • Swagger 문서 및 성공/실패 응답 예시 추가

👀 변경 사항

  • 기존 이슈에는 repositoryId 기준 조회로 작성되어 있었지만, 현재 분석 요청 생성 API가 analysisId를 반환하므로 analysisId 기준으로 API를 구현했습니다.
  • 응답 필드는 analysisId, analysisStatus, progressPercent, failureReason입니다.
  • 프론트에서는 분석 요청 생성 응답의 analysisId를 저장한 뒤 해당 ID로 폴링하면 됩니다.

📸 스크린샷 (Optional)

스크린샷 2026-06-12 20 42 42 스크린샷 2026-06-12 20 42 17

✅ 체크리스트

  • label, milestone, assignees, reviewers 등을 지정했습니다.
  • 성능 개선/최적화 관련 내용이 있는지 확인했습니다.
  • 변경 사항에 대한 테스트를 했습니다.
  • 테스트 시 사용한 로그를 삭제했습니다.

💬 고민사항 및 리뷰 요구사항 (Optional)

이슈에는 repositoryId 기준 상태 조회로 되어 있었지만, 분석 상태는 analyses 단위의 상태이므로 analysisId 기준 조회가 더 적절하다고 판단했습니다.

Summary by CodeRabbit

  • 새로운 기능
    • 진행 중인 분석의 상태를 조회할 수 있는 API GET /api/analysis/request/{analysisId}/status가 추가되었습니다.
    • 응답에는 분석 ID, 진행률, 실패 사유가 포함되어 상세 상태를 확인할 수 있습니다.
  • 개선 사항
    • 상태 조회 과정에서 요청 사용자 기준의 검증을 강화하여, 해당 분석에 대한 접근 권한이 맞는 경우에만 정확한 상태가 반환되도록 개선했습니다.

@dldusgh318 dldusgh318 added this to the 분석 요청 API 구현 milestone Jun 12, 2026
@dldusgh318 dldusgh318 requested a review from boogiewooki02 June 12, 2026 11:45
@dldusgh318 dldusgh318 self-assigned this Jun 12, 2026
@dldusgh318 dldusgh318 added the ✨ FEAT New feature or request label Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8eb215b3-6d41-4c30-b8c6-d46029c8d441

📥 Commits

Reviewing files that changed from the base of the PR and between 45cc764 and 15abee8.

📒 Files selected for processing (1)
  • src/main/java/SeCause/SeCause_be/domain/analysis/dto/AnalysisRequestStatusResponse.java

📝 Walkthrough

안내

이 PR은 분석 상태 조회 기능을 구현하며, 프론트엔드에서 폴링 방식으로 분석 진행 상황을 확인할 수 있도록 합니다.

변경 사항

분석 상태 조회 API

계층 / 파일 요약
응답 DTO 정의
src/main/java/SeCause/SeCause_be/domain/analysis/dto/AnalysisRequestStatusResponse.java
analysisId, analysisStatus, progressPercent, failureReason 필드를 가진 레코드 DTO를 추가하고, Analysis 엔티티에서 데이터를 매핑하는 from() 메서드를 구현합니다.
데이터 로딩 최적화
src/main/java/SeCause/SeCause_be/domain/analysis/repository/AnalysisRepository.java
리포지토리 메서드를 findWithRepositoryAndUserByAnalysisId로 변경하여 엔티티 그래프를 확장합니다. 분석 조회 시 저장소와 사용자 정보를 함께 로딩하도록 구성합니다.
서비스 로직 구현
src/main/java/SeCause/SeCause_be/domain/analysis/service/AnalysisRequestService.java
getAnalysisRequestStatus(userId, analysisId) 메서드를 구현합니다. 요청 사용자의 소유권을 검증하고, 불일치하거나 분석이 없으면 ANALYSIS_RESULT_NOT_FOUND 예외를 발생시킵니다.
API 엔드포인트
src/main/java/SeCause/SeCause_be/domain/analysis/controller/AnalysisRequestApi.java
src/main/java/SeCause/SeCause_be/domain/analysis/controller/AnalysisRequestController.java
GET /api/analysis/request/{analysisId}/status 엔드포인트를 추가합니다. 인터페이스에서 OpenAPI 문서화(200/401/404 응답)를 정의하고, 컨트롤러에서 서비스를 호출하여 ApiResponse로 래핑한 결과를 반환합니다.

예상 코드 리뷰 난이도

🎯 2 (Simple) | ⏱️ ~12 분

관련 PR

  • SeCause/SeCause-BE#35: 동일한 AnalysisRepository의 메서드 시그니처 변경으로 인해 기존 분석 처리 로직(AnalysisDispatchService)이 영향을 받으므로 함께 검토가 필요합니다.

축하 시

🐰 분석 상태를 담은 API,
폴링으로 진행률 확인,
한 번, 또 한 번, 또 한 번,
완성될 때까지 쿼리날리고,
상태 업데이트와 함께 춤을 춘다! 💃

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경 사항의 주요 내용을 정확하게 반영하고 있으며, 분석 상태 조회 API 구현이라는 핵심 기능을 명확하게 전달합니다.
Linked Issues check ✅ Passed 분석 상태 조회 API 엔드포인트, DTO 정의, analyses 테이블의 status/progress_percent/failure_reason 필드 조회가 모두 구현되었으며, 404 에러 처리도 포함되어 있습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 분석 상태 조회 API 구현이라는 범위 내에 있으며, 불필요한 외부 변경사항은 없습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@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/SeCause/SeCause_be/domain/analysis/dto/AnalysisRequestStatusResponse.java`:
- Around line 13-18: The response currently uses
analysis.getAnalysisStatus().getDescription() (e.g., a localized label); change
AnalysisRequestStatusResponse.from(Analysis) to return the contract enum value
instead — use analysis.getAnalysisStatus().name() or include the AnalysisStatus
value itself rather than getDescription() so the API emits codes like
IN_PROGRESS/FAILED; keep display labels (getDescription()) out of this DTO and
move them to the UI or a separate field if needed.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 99782cd1-2fcc-42a5-b753-02b544891d6e

📥 Commits

Reviewing files that changed from the base of the PR and between 36a3dbc and 45cc764.

📒 Files selected for processing (5)
  • src/main/java/SeCause/SeCause_be/domain/analysis/controller/AnalysisRequestApi.java
  • src/main/java/SeCause/SeCause_be/domain/analysis/controller/AnalysisRequestController.java
  • src/main/java/SeCause/SeCause_be/domain/analysis/dto/AnalysisRequestStatusResponse.java
  • src/main/java/SeCause/SeCause_be/domain/analysis/repository/AnalysisRepository.java
  • src/main/java/SeCause/SeCause_be/domain/analysis/service/AnalysisRequestService.java

@boogiewooki02 boogiewooki02 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.

고생하셨습니다!
코드리뷰 부분은 따로 없어 이대로 머지하시면 될 것 같아요!

@dldusgh318 dldusgh318 merged commit c4955f3 into SeCause:develop Jun 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ FEAT New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 분석 상태 조회 API

2 participants