From eda00efb0126882332714c60663414a7ff1f12b3 Mon Sep 17 00:00:00 2001 From: Rui Alves Date: Thu, 10 Oct 2024 19:20:10 +0100 Subject: [PATCH] Updated documentation for the review/summary endpoint --- docs/static/frigate-api.yaml | 84 ++++++++++++++++++++++++++++++++++-- frigate/api/review.py | 7 ++- 2 files changed, 86 insertions(+), 5 deletions(-) diff --git a/docs/static/frigate-api.yaml b/docs/static/frigate-api.yaml index 56b31c9f8..7609890a7 100644 --- a/docs/static/frigate-api.yaml +++ b/docs/static/frigate-api.yaml @@ -277,7 +277,8 @@ paths: description: Successful Response content: application/json: - schema: { } + schema: + $ref: '#/components/schemas/ReviewSummaryResponse' '422': description: Validation Error content: @@ -2368,14 +2369,14 @@ paths: required: false schema: type: number - default: 1728577904.036181 + default: 1728580419.15206 title: After - name: before in: query required: false schema: type: number - default: 1728581504.0362 + default: 1728584019.152614 title: Before responses: '200': @@ -3186,6 +3187,40 @@ components: required: - password title: AppPutPasswordBody + DayReview: + properties: + day: + type: string + format: date-time + title: Day + reviewed_alert: + type: integer + title: Reviewed Alert + reviewed_detection: + type: integer + title: Reviewed Detection + reviewed_motion: + type: integer + title: Reviewed Motion + total_alert: + type: integer + title: Total Alert + total_detection: + type: integer + title: Total Detection + total_motion: + type: integer + title: Total Motion + type: object + required: + - day + - reviewed_alert + - reviewed_detection + - reviewed_motion + - total_alert + - total_detection + - total_motion + title: DayReview EventsCreateBody: properties: source_type: @@ -3280,6 +3315,35 @@ components: title: Detail type: object title: HTTPValidationError + Last24HoursReview: + properties: + reviewed_alert: + type: integer + title: Reviewed Alert + reviewed_detection: + type: integer + title: Reviewed Detection + reviewed_motion: + type: integer + title: Reviewed Motion + total_alert: + type: integer + title: Total Alert + total_detection: + type: integer + title: Total Detection + total_motion: + type: integer + title: Total Motion + type: object + required: + - reviewed_alert + - reviewed_detection + - reviewed_motion + - total_alert + - total_detection + - total_motion + title: Last24HoursReview RegenerateDescriptionEnum: type: string enum: @@ -3323,6 +3387,20 @@ components: - thumb_path - data title: ReviewSegmentResponse + ReviewSummaryResponse: + properties: + last24Hours: + $ref: '#/components/schemas/Last24HoursReview' + root: + additionalProperties: + $ref: '#/components/schemas/DayReview' + type: object + title: Root + type: object + required: + - last24Hours + - root + title: ReviewSummaryResponse SeverityEnum: type: string enum: diff --git a/frigate/api/review.py b/frigate/api/review.py index ed3d041d8..740f9f0c9 100644 --- a/frigate/api/review.py +++ b/frigate/api/review.py @@ -17,7 +17,10 @@ from frigate.api.defs.review_query_parameters import ( ReviewQueryParams, ReviewSummaryQueryParams, ) -from frigate.api.defs.review_responses import ReviewSegmentResponse +from frigate.api.defs.review_responses import ( + ReviewSegmentResponse, + ReviewSummaryResponse, +) from frigate.api.defs.tags import Tags from frigate.models import Recordings, ReviewSegment from frigate.util.builtin import get_tz_modifiers @@ -103,7 +106,7 @@ def review(params: ReviewQueryParams = Depends()): return JSONResponse(content=[r for r in review]) -@router.get("/review/summary") +@router.get("/review/summary", response_model=ReviewSummaryResponse) def review_summary(params: ReviewSummaryQueryParams = Depends()): hour_modifier, minute_modifier, seconds_offset = get_tz_modifiers(params.timezone) day_ago = (datetime.datetime.now() - datetime.timedelta(hours=24)).timestamp()