Skip to content

[WBS - 104 ~ 107]통계 API 구현 - #43

Merged
gusals1213 merged 6 commits into
devfrom
feature/statistics
Aug 8, 2026
Merged

gusals1213 merged 6 commits into
devfrom
feature/statistics

Conversation

@gusals1213

@gusals1213 gusals1213 commented Aug 8, 2026 •

Copy link
Copy Markdown
Collaborator

📄 작업 내용

구현 내용

부스 및 행사 운영 통계 API 4개를 구현했습니다.

STAT-API-001 GET /booths/{boothId}/statistics/hourly

  • 특정 날짜의 시간대별(0~23시) 부스 통계 조회
  • date 파라미터 미입력 시 오늘 날짜 기본 사용
  • 접근 권한: PLATFORM_ADMIN / EVENT_MANAGER / 배정된 참가기업 조직원

STAT-API-002 GET /booths/{boothId}/statistics/previous-day

  • 전날 시간대별 통계를 합산하여 반환 (총 예약·노쇼·QR 스캔수 포함)
  • 접근 권한: STAT-API-001과 동일

STAT-API-003 GET /events/{eventId}/statistics/popular-booths

  • 기간별 부스별 예약수 합계 기준 인기 순위 반환
  • 접근 권한: PLATFORM_ADMIN / EVENT_MANAGER

STAT-API-004 GET /events/{eventId}/statistics/overview

  • 기간별 행사 전체 합산 통계 + 부스별 요약 목록 반환
  • 접근 권한: PLATFORM_ADMIN / EVENT_MANAGER

주요 설계 사항

  • BoothStatAggregation Projection으로 JPQL 집계 쿼리 결과를 타입 안전하게 처리
  • aggregateByBoothIdsAndDateBetween() 쿼리를 STAT-API-003·004에서 공통 재사용
  • 비로그인 → 401, 권한 없음 → 403으로 명시적 처리

🔗 관련 이슈

Closes #

☑️ 체크리스트

  • 로컬에서 정상 동작 확인
  • 테스트 작성 및 통과
  • 불필요한 로그/주석/커밋 정리

💬 리뷰어에게

  • 통계 데이터가 booth_hourly_statistics 테이블에 직접 INSERT 되어 있어야 테스트 가능합니다. (현재 집계 스케줄러 미구현)
  • STAT-API-003·004의 from, to는 필수 파라미터입니다. 기본값 정책이 필요하다면 논의 부탁드립니다.

Summary by CodeRabbit

  • 새 기능

    • 부스별 시간대 통계를 날짜 기준으로 조회할 수 있습니다. 날짜를 입력하지 않으면 오늘 기준으로 조회됩니다.
    • 전날의 예약, 노쇼, QR 스캔 실적을 한눈에 확인할 수 있습니다.
    • 기간별 인기 부스를 예약 건수 기준으로 확인할 수 있습니다.
    • 행사 전체의 예약·노쇼·QR 스캔 현황과 부스별 운영 요약을 제공합니다.
    • 통계 조회 시 권한과 접근 가능한 행사·부스를 검증합니다.
  • 개선

    • 유효하지 않은 기간을 입력하면 명확한 오류를 안내합니다.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fc0dae75-95b0-4956-be4e-0203c9e17e9e

📥 Commits

Reviewing files that changed from the base of the PR and between 8aa507f and bdbfcc3.

📒 Files selected for processing (3)
  • BE/src/main/java/com/min/edu/booth/controller/BoothStatisticsController.java
  • BE/src/main/java/com/min/edu/booth/repository/BoothHourlyStatisticsRepository.java
  • BE/src/main/java/com/min/edu/booth/service/BoothStatisticsService.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • BE/src/main/java/com/min/edu/booth/repository/BoothHourlyStatisticsRepository.java
  • BE/src/main/java/com/min/edu/booth/controller/BoothStatisticsController.java
  • BE/src/main/java/com/min/edu/booth/service/BoothStatisticsService.java

Walkthrough

부스 및 행사 통계 조회 기능을 추가했다. 네 개의 GET API가 시간대별 통계, 전날 통계, 인기 부스, 행사 운영 요약을 제공한다. 서비스는 집계 조회와 인증·역할 기반 접근 권한을 처리한다.

Changes

부스 통계 조회

Layer / File(s) Summary
통계 응답 계약과 집계 조회
BE/src/main/java/com/min/edu/booth/dto/BoothStatisticsDtos.java, BE/src/main/java/com/min/edu/booth/repository/BoothStatAggregation.java, BE/src/main/java/com/min/edu/booth/repository/BoothHourlyStatisticsRepository.java, BE/src/main/java/com/min/edu/booth/repository/BoothRepository.java
시간대별·전날·인기 부스·행사 요약용 record와 기간 집계 Projection을 추가했다. 시간대별 조회는 시간 오름차순으로 반환한다. 기간 집계는 예약 수 내림차순과 부스 ID 오름차순으로 정렬한다.
통계 서비스와 접근 권한
BE/src/main/java/com/min/edu/booth/service/BoothStatisticsService.java
통계 조회 전에 인증, 부스·행사 존재 여부, 역할과 부스 배정을 검증한다. 허용 대상은 플랫폼 관리자, 활성 행사 관리자, 배정 부스의 활성 참가기업 조직원이다. 조회 결과를 통계 DTO로 변환한다.
통계 API 엔드포인트 연결
BE/src/main/java/com/min/edu/booth/controller/BoothStatisticsController.java
시간대별 통계, 전날 통계, 인기 부스, 행사 운영 요약 GET API를 추가했다. 날짜가 없으면 오늘 날짜를 사용한다. 역전된 기간은 INVALID_INPUT_VALUE 예외로 처리한다. 결과는 ApiResponse.success로 반환한다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant BoothStatisticsController
  participant BoothStatisticsService
  participant BoothHourlyStatisticsRepository
  Client->>BoothStatisticsController: GET 통계 조회 요청
  BoothStatisticsController->>BoothStatisticsController: 날짜 기본값 또는 기간 검증
  BoothStatisticsController->>BoothStatisticsService: 파라미터와 인증 회원 전달
  BoothStatisticsService->>BoothStatisticsService: 인증·리소스·역할 권한 검증
  BoothStatisticsService->>BoothHourlyStatisticsRepository: 시간대별 또는 기간별 집계 조회
  BoothHourlyStatisticsRepository-->>BoothStatisticsService: 통계 집계 결과 반환
  BoothStatisticsService-->>BoothStatisticsController: 통계 응답 DTO 반환
  BoothStatisticsController-->>Client: ApiResponse.success 응답
Loading

Possibly related PRs

  • half-fifty/eventoday#28: 예약 생성·취소와 예약 수 갱신을 다룬다. 이 PR은 해당 예약 수를 통계로 집계한다.
  • half-fifty/eventoday#31: 동일한 BoothRepository를 사용한다. 이 PR은 행사별 부스 조회 메서드를 추가한다.
  • half-fifty/eventoday#34: 예약 및 노쇼 처리 데이터를 다룬다. 이 PR은 해당 데이터를 기간별 통계로 집계한다.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 부스 및 행사 통계 API 구현이라는 변경 사항을 명확하게 요약한 제목입니다.
Description check ✅ Passed 주요 구현 내용, 권한, 설계 사항, 체크리스트와 테스트 조건을 구체적으로 설명했습니다.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 feature/statistics

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 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
`@BE/src/main/java/com/min/edu/booth/controller/BoothStatisticsController.java`:
- Around line 50-51: BoothStatisticsController의
getPopularBooths(BE/src/main/java/com/min/edu/booth/controller/BoothStatisticsController.java:50-51)와
getEventOverview(BE/src/main/java/com/min/edu/booth/controller/BoothStatisticsController.java:62-63)
호출 전에 공통 기간 검증을 적용하세요. from.isAfter(to)인 경우 두 API 모두 400 응답을 반환하도록 공통 검증 메서드 또는
요청 검증 객체를 사용하고, 정상적인 기간은 기존 서비스 호출로 계속 전달하세요.

In
`@BE/src/main/java/com/min/edu/booth/repository/BoothHourlyStatisticsRepository.java`:
- Around line 21-29: Update the query used by BoothHourlyStatisticsRepository to
add a deterministic secondary sort by bhs.boothId ascending after the
reservation-count aggregate ordering, preserving the existing descending ranking
criterion.

In `@BE/src/main/java/com/min/edu/booth/service/BoothStatisticsService.java`:
- Around line 229-242: Update the summary construction around aggregations and
boothCodeMap so every booth in boothCodeMap produces a
BoothStatisticsDtos.BoothStatSummary, including booths without matching
aggregation rows. Reuse matching aggregation values when present; otherwise set
total reservation, no-show, and QR scan counts to 0, while preserving the
existing booth ID and code mapping.
🪄 Autofix

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: f55e4c97-b604-4687-8656-df8d76c591ac

📥 Commits

Reviewing files that changed from the base of the PR and between 15b249f and 8aa507f.

📒 Files selected for processing (6)
  • BE/src/main/java/com/min/edu/booth/controller/BoothStatisticsController.java
  • BE/src/main/java/com/min/edu/booth/dto/BoothStatisticsDtos.java
  • BE/src/main/java/com/min/edu/booth/repository/BoothHourlyStatisticsRepository.java
  • BE/src/main/java/com/min/edu/booth/repository/BoothRepository.java
  • BE/src/main/java/com/min/edu/booth/repository/BoothStatAggregation.java
  • BE/src/main/java/com/min/edu/booth/service/BoothStatisticsService.java

Comment thread BE/src/main/java/com/min/edu/booth/service/BoothStatisticsService.java Outdated
@gusals1213 gusals1213 changed the title [WBS - 104 ~ 10em7]통계 API 구현 [WBS - 104 ~ 107]통계 API 구현 Aug 8, 2026
@gusals1213
gusals1213 merged commit 101833b into dev Aug 8, 2026
1 check passed
@LeeWonGun
LeeWonGun deleted the feature/statistics branch August 26, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant