mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-27 14:18:57 +03:00
fix frozen time bounds on the recordings API (#24121)
`after` and `before` defaulted to `datetime.now()` in the function signature, so they were evaluated once at import. Requests that omitted them got a window ending at process start. They now resolve in the handler.
This commit is contained in:
committed by
Nicolas Mowen
parent
e2da7aae99
commit
9416e74aeb
@@ -358,10 +358,13 @@ async def recordings_coverage(
|
||||
@router.get("/{camera_name}/recordings", dependencies=[Depends(require_camera_access)])
|
||||
async def recordings(
|
||||
camera_name: str,
|
||||
after: float = (datetime.now() - timedelta(hours=1)).timestamp(),
|
||||
before: float = datetime.now().timestamp(),
|
||||
after: float | None = None,
|
||||
before: float | None = None,
|
||||
):
|
||||
"""Return specific camera recordings between the given 'after'/'end' times. If not provided the last hour will be used"""
|
||||
now = datetime.now()
|
||||
after = after if after is not None else (now - timedelta(hours=1)).timestamp()
|
||||
before = before if before is not None else now.timestamp()
|
||||
recordings = (
|
||||
Recordings.select(
|
||||
Recordings.id,
|
||||
|
||||
Reference in New Issue
Block a user