mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 02:35:22 +03:00
Make timeline cleanup simpler
This commit is contained in:
parent
1871a7b0bb
commit
e30ff66f69
@ -95,14 +95,6 @@ class RecordingCleanup(threading.Thread):
|
|||||||
.objects()
|
.objects()
|
||||||
)
|
)
|
||||||
|
|
||||||
timeline: Timeline = (
|
|
||||||
Timeline.select(Timeline.timestamp)
|
|
||||||
.where(Timeline.camera == camera, Timeline.timestamp < expire_date)
|
|
||||||
.order_by(Timeline.timestamp)
|
|
||||||
.objects()
|
|
||||||
.iterator()
|
|
||||||
)
|
|
||||||
|
|
||||||
# loop over recordings and see if they overlap with any non-expired events
|
# loop over recordings and see if they overlap with any non-expired events
|
||||||
# TODO: expire segments based on segment stats according to config
|
# TODO: expire segments based on segment stats according to config
|
||||||
event_start = 0
|
event_start = 0
|
||||||
@ -149,12 +141,11 @@ class RecordingCleanup(threading.Thread):
|
|||||||
deleted_recordings.add(recording.id)
|
deleted_recordings.add(recording.id)
|
||||||
|
|
||||||
# delete timeline entries relevant to this recording segment
|
# delete timeline entries relevant to this recording segment
|
||||||
for time in [
|
Timeline.delete(
|
||||||
t
|
Timeline.timestamp.between(recording.start_time, recording.end_time),
|
||||||
for t in timeline
|
Timeline.timestamp < expire_date,
|
||||||
if recording.start_time < t.timestamp < recording.end_time
|
Timeline.camera == camera,
|
||||||
]:
|
).execute()
|
||||||
Timeline.delete().where(Timeline.timestamp == time.timestamp)
|
|
||||||
|
|
||||||
logger.debug(f"Expiring {len(deleted_recordings)} recordings")
|
logger.debug(f"Expiring {len(deleted_recordings)} recordings")
|
||||||
# delete up to 100,000 at a time
|
# delete up to 100,000 at a time
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user