Keep post capture after review items end (#24726)

* keep post capture segments after a review item ends

The recording maintainer only loaded review items whose end_time was after the oldest cached segment, so once an item closed in the database the segments in its post_capture window no longer matched it. With continuous recording off and no motion after the item, everything past roughly the review cutoff_time was deleted from the cache instead of being kept for the full post_capture. The query bound now subtracts the camera's largest post_capture, and the per-item check still decides the exact cutoff.

* fix mypy and add docstring
This commit is contained in:
Josh Hawkins
2026-10-23 06:25:21 -06:00
committed by GitHub
parent a85526187e
commit 6e185ed36e
3 changed files with 69 additions and 3 deletions
+11 -3
View File
@@ -471,9 +471,14 @@ class RecordingMaintainer(threading.Thread):
for key, recordings in grouped_recordings.items():
camera, stream_type = key
# get all reviews with the end time after the start of the oldest
# cache file or with end_time None; shared across stream types
# get all reviews whose post capture reaches the oldest cache file
# or with end_time None; shared across stream types
if camera not in reviews_by_camera:
post_capture = (
self.config.cameras[camera].record.event_post_capture
if camera in self.config.cameras
else 0
)
reviews_by_camera[camera] = (
ReviewSegment.select(
ReviewSegment.start_time,
@@ -484,7 +489,10 @@ class RecordingMaintainer(threading.Thread):
.where(
ReviewSegment.camera == camera,
(ReviewSegment.end_time == None)
| (ReviewSegment.end_time >= min_start_per_camera[camera]),
| (
ReviewSegment.end_time
>= min_start_per_camera[camera] - post_capture
),
)
.order_by(ReviewSegment.start_time)
)