diff --git a/frigate/api/defs/events_body.py b/frigate/api/defs/events_body.py index bfcb2610b..7aef87433 100644 --- a/frigate/api/defs/events_body.py +++ b/frigate/api/defs/events_body.py @@ -1,4 +1,3 @@ -from datetime import datetime from typing import Optional, Union from pydantic import BaseModel, Field @@ -27,7 +26,7 @@ class EventsCreateBody(BaseModel): class EventsEndBody(BaseModel): - end_time: Optional[int] = datetime.now().timestamp() + end_time: Optional[int] = None class SubmitPlusBody(BaseModel): diff --git a/frigate/api/defs/review_query_parameters.py b/frigate/api/defs/review_query_parameters.py index 795531c17..a3f63d292 100644 --- a/frigate/api/defs/review_query_parameters.py +++ b/frigate/api/defs/review_query_parameters.py @@ -1,4 +1,3 @@ -from datetime import datetime, timedelta from typing import Optional from pydantic import BaseModel @@ -11,8 +10,8 @@ class ReviewQueryParams(BaseModel): reviewed: Optional[int] = 0 limit: Optional[int] = None severity: Optional[str] = None - before: Optional[float] = datetime.now().timestamp() - after: Optional[float] = (datetime.now() - timedelta(hours=24)).timestamp() + before: Optional[float] = None + after: Optional[float] = None class ReviewSummaryQueryParams(BaseModel): @@ -24,6 +23,6 @@ class ReviewSummaryQueryParams(BaseModel): class ReviewActivityMotionQueryParams(BaseModel): cameras: Optional[str] = "all" - before: Optional[float] = datetime.now().timestamp() - after: Optional[float] = (datetime.now() - timedelta(hours=1)).timestamp() + before: Optional[float] = None + after: Optional[float] = None scale: Optional[int] = 30 diff --git a/frigate/api/event.py b/frigate/api/event.py index 74e93b5dd..556d19909 100644 --- a/frigate/api/event.py +++ b/frigate/api/event.py @@ -1,6 +1,7 @@ """Event apis.""" import base64 +import datetime import io import logging import os @@ -1073,7 +1074,7 @@ def create_event( @router.put("/events/{event_id}/end") def end_event(request: Request, event_id: str, body: EventsEndBody): try: - end_time = body.end_time + end_time = body.end_time or datetime.datetime.now().timestamp() request.app.external_processor.finish_manual_event(event_id, end_time) except Exception: return JSONResponse( diff --git a/frigate/api/review.py b/frigate/api/review.py index eb71b6125..7c05386ef 100644 --- a/frigate/api/review.py +++ b/frigate/api/review.py @@ -34,8 +34,11 @@ def review(params: ReviewQueryParams = Depends()): reviewed = params.reviewed limit = params.limit severity = params.severity - before = params.before - after = params.after + before = params.before or datetime.datetime.now().timestamp() + after = ( + params.after + or (datetime.datetime.now() - datetime.timedelta(hours=24)).timestamp() + ) clauses = [ ( @@ -425,8 +428,11 @@ def delete_reviews(body: dict = None): def motion_activity(params: ReviewActivityMotionQueryParams = Depends()): """Get motion and audio activity.""" cameras = params.cameras - before = params.before - after = params.after + before = params.before or datetime.datetime.now().timestamp() + after = ( + params.after + or (datetime.datetime.now() - datetime.timedelta(hours=1)).timestamp() + ) # get scale in seconds scale = params.scale @@ -496,8 +502,11 @@ def motion_activity(params: ReviewActivityMotionQueryParams = Depends()): def audio_activity(params: ReviewActivityMotionQueryParams = Depends()): """Get motion and audio activity.""" cameras = params.cameras - before = params.before - after = params.after + before = params.before or datetime.datetime.now().timestamp() + after = ( + params.after + or (datetime.datetime.now() - datetime.timedelta(hours=1)).timestamp() + ) # get scale in seconds scale = params.scale