mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-06 19:25:22 +03:00
Reduce database queries to necessary labels
This commit is contained in:
parent
5658e5a4cc
commit
3fa5a41b60
@ -83,7 +83,10 @@ class EventCleanup(threading.Thread):
|
||||
datetime.datetime.now() - datetime.timedelta(days=expire_days)
|
||||
).timestamp()
|
||||
# grab all events after specific time
|
||||
expired_events = Event.select().where(
|
||||
expired_events = Event.select(
|
||||
Event.id,
|
||||
Event.camera,
|
||||
).where(
|
||||
Event.camera.not_in(self.camera_keys),
|
||||
Event.start_time < expire_after,
|
||||
Event.label == event.label,
|
||||
|
||||
@ -89,7 +89,10 @@ class RecordingCleanup(threading.Thread):
|
||||
|
||||
# Get all the events to check against
|
||||
events: Event = (
|
||||
Event.select()
|
||||
Event.select(
|
||||
Event.start_time,
|
||||
Event.end_time,
|
||||
)
|
||||
.where(
|
||||
Event.camera == camera,
|
||||
# need to ensure segments for all events starting
|
||||
@ -109,7 +112,7 @@ class RecordingCleanup(threading.Thread):
|
||||
keep = False
|
||||
# Now look for a reason to keep this recording segment
|
||||
for idx in range(event_start, len(events)):
|
||||
event = events[idx]
|
||||
event: Event = events[idx]
|
||||
|
||||
# if the event starts in the future, stop checking events
|
||||
# and let this recording segment expire
|
||||
|
||||
Loading…
Reference in New Issue
Block a user