mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Do not use a default value of datetime for params (#13957)
* Do not use a default value of datetime for params * Formatting * Remove unused * Undo
This commit is contained in:
parent
4c12673fbb
commit
4c24b70d47
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user