feat(events): GET /api/events 응답에 event_type/reason 노출 + status 값 정규화 - #23
Merged
Hidden character warning
The head ref may contain hidden characters: "feature/\uc870\uc218\uadfc-event-type-reason"
Conversation
요청: GET /api/events/ 응답에 event_type(항상 포함), reason(false_alarm 일 때만) 받고 싶음. 확인 결과 event_type 은 모델에는 있는데 EventResponse 에 빠져 있었고, reason 은 컬럼 자체가 없었음(POST /false-alarm 받아만 두고 DB 미저장, broadcast 만 함). 또 frontend(이지현 PR #15) 가 status='false_alarm' 을 기대하는데 backend 는 'dismissed' 로 박고 있어 표시도 깨지는 상태였음. 변경: - models.Event: reason String NULL 컬럼 추가, status/event_type 주석 정정 - schemas.EventResponse: event_type(str), reason(Optional[str]) 필드 추가 - schemas.EventCreate: event_type Optional 추가 (AI 분류 결과 동행) - schemas.EventStatusUpdate: Literal['confirmed','false_alarm'] (dismissed 제거) - api.report_false_alarm: status='false_alarm', event.reason=body.reason 저장 - api.create_event: model_dump(exclude_none=True) — 모델 default 적용 보장 - api.get_event_stats: false_alarm_count 쿼리 status='false_alarm' - alembic c1a2b3d4e5f6: events.reason 추가 + 기존 status='dismissed' 행을 'false_alarm' 으로 백필 (운영 DB 손상 없이 표준화) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
팀원 요청 — `GET /api/events/` 응답에 `event_type` (항상 포함) 과 `reason` (status='false_alarm' 일 때만) 두 필드 받고 싶음.
확인 중 추가 발견:
세 가지 한 PR로 정리.
변경
머지 후 응답 예
```json
{
"id": 42,
"camera_id": 7,
"timestamp": "2026-05-11T08:00:00",
"status": "false_alarm",
"event_type": "tailgating",
"reason": "그림자 오감지",
"clip_url": "...",
"..."
}
```
마이그레이션
변경사항