Reduce database queries to necessary fields (#7751)

* Reduce database queries to necessary labels

* Set columns for other queries

* skip creating model instances

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
This commit is contained in:
Nicolas Mowen
2023-09-11 16:07:04 -06:00
committed by GitHub
parent 5658e5a4cc
commit a2206bb177
5 changed files with 62 additions and 23 deletions

View File

@@ -152,7 +152,10 @@ class RecordingMaintainer(threading.Thread):
# get all events with the end time after the start of the oldest cache file
# or with end_time None
events: Event = (
Event.select()
Event.select(
Event.start_time,
Event.end_time,
)
.where(
Event.camera == camera,
(Event.end_time == None)