Skip to content

feat(api): events 페이지네이션 메타 + 통계 3종 + notifications 정리#31

Merged
CHOSOOGEUN merged 1 commit into
masterfrom
feature/조수근-events-stats-pagination
May 23, 2026

Hidden character warning

The head ref may contain hidden characters: "feature/\uc870\uc218\uadfc-events-stats-pagination"
Merged

feat(api): events 페이지네이션 메타 + 통계 3종 + notifications 정리#31
CHOSOOGEUN merged 1 commit into
masterfrom
feature/조수근-events-stats-pagination

Conversation

@CHOSOOGEUN

Copy link
Copy Markdown
Owner

팀원 피드백 #1, #2, #4 마저 처리.

#1 — notifications 정리

  • POST /api/notifications/read-all 삭제 (frontend 미사용 + 인증 없는 broad-update 로 위험)
  • PATCH /api/notifications/{id}/readcurrent_admin 인증 추가 (이전엔 누락 상태)

#2GET /api/events/ 페이지네이션 메타 (X-Total-Count 헤더)

  • 응답 본문 형식은 그대로 list[EventResponse] 유지 (frontend 무파괴)
  • 필터 적용된 전체 건수를 X-Total-Count 헤더로 노출
  • CORSMiddleware(expose_headers=['X-Total-Count']) 설정해 cross-origin 클라도 헤더 접근 가능
  • frontend 에서 res.headers['x-total-count'] 로 총 페이지 표시 가능

#4 — StatsPage 서버 통계 3종

  • GET /api/events/stats/by-type — event_type 별 카운트 (EventTypeChart)
  • GET /api/events/stats/hourly — 시간대(0~23)별 카운트, date_from/date_to 옵션 (HourlyDistributionChart)
  • GET /api/events/stats/daily?days=30 — 일자별 추이, 기본 최근 30일 (DailyTrendChart)

기존 /stats, /stats/by-camera 는 그대로 유지.

변경

  • backend/app/api/events.py
  • backend/app/api/notifications.py
  • backend/app/main.py (CORSMiddleware expose_headers)

변경사항

  • 신규 기능 (페이지네이션 메타, 통계 3종)
  • 정리 (read-all 제거, read 인증 보강)

팀원 피드백 3종 마저 처리.

#1 — notifications 'read-all' API 삭제 + 'read' 인증 보강
- frontend 가 read-all 미사용. 인증 없는 broad-update 는 보안 위험이라
  엔드포인트 자체 제거.
- 개별 read 핸들러는 인증(current_admin) 누락 상태였음 → 추가.

#2 — GET /api/events/ 응답에 X-Total-Count 헤더
- 필터 적용된 전체 건수를 헤더로 노출 (응답 본문 형식은 그대로
  list[EventResponse] 유지 — frontend 무파괴).
- frontend 는 res.headers['x-total-count'] 로 읽어 총 페이지 표시 가능.
- CORSMiddleware 에 expose_headers=['X-Total-Count'] 추가
  (cross-origin 클라가 헤더 읽도록 보장).

#4 — StatsPage 용 서버 통계 3종 추가
- GET /api/events/stats/by-type  — event_type 별 카운트
- GET /api/events/stats/hourly   — 시간대(0~23)별 카운트
  (date_from/date_to 옵션)
- GET /api/events/stats/daily?days=30 — 일자별 추이 (기본 최근 30일)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CHOSOOGEUN CHOSOOGEUN merged commit 93d5849 into master May 23, 2026
1 check passed
@CHOSOOGEUN CHOSOOGEUN deleted the feature/조수근-events-stats-pagination branch May 23, 2026 02:23
CHOSOOGEUN added a commit that referenced this pull request May 23, 2026
…-wiring

feat(frontend,mobile,ai): PR #30/#31 새 API/헤더 클라이언트 일괄 연결
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