treewide: apply black

This commit is contained in:
Martin Weinelt 2023-05-23 03:49:39 +02:00
parent 3fc4e7be0a
commit bc4071dde8
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759
4 changed files with 13 additions and 10 deletions

View File

@ -90,7 +90,9 @@ class EventCleanup(threading.Thread):
# loop over object types in db # loop over object types in db
for event in distinct_labels: for event in distinct_labels:
# get expiration time for this label # get expiration time for this label
expire_days = retain_config.objects.get(event.label, retain_config.default) expire_days = retain_config.objects.get(
event.label, retain_config.default
)
expire_after = ( expire_after = (
datetime.datetime.now() - datetime.timedelta(days=expire_days) datetime.datetime.now() - datetime.timedelta(days=expire_days)
).timestamp() ).timestamp()

View File

@ -177,11 +177,7 @@ class TrackedObject:
return (thumb_update, significant_change) return (thumb_update, significant_change)
def to_dict(self, include_thumbnail: bool = False): def to_dict(self, include_thumbnail: bool = False):
( (self.thumbnail_data["frame_time"] if self.thumbnail_data is not None else 0.0)
self.thumbnail_data["frame_time"]
if self.thumbnail_data is not None
else 0.0
)
event = { event = {
"id": self.obj_data["id"], "id": self.obj_data["id"],
"camera": self.camera, "camera": self.camera,

View File

@ -30,9 +30,15 @@ def migrate(migrator, database, fake=False, **kwargs):
migrator.sql( migrator.sql(
'CREATE TABLE IF NOT EXISTS "timeline" ("timestamp" DATETIME NOT NULL, "camera" VARCHAR(20) NOT NULL, "source" VARCHAR(20) NOT NULL, "source_id" VARCHAR(30), "class_type" VARCHAR(50) NOT NULL, "data" JSON)' 'CREATE TABLE IF NOT EXISTS "timeline" ("timestamp" DATETIME NOT NULL, "camera" VARCHAR(20) NOT NULL, "source" VARCHAR(20) NOT NULL, "source_id" VARCHAR(30), "class_type" VARCHAR(50) NOT NULL, "data" JSON)'
) )
migrator.sql('CREATE INDEX IF NOT EXISTS "timeline_camera" ON "timeline" ("camera")') migrator.sql(
migrator.sql('CREATE INDEX IF NOT EXISTS "timeline_source" ON "timeline" ("source")') 'CREATE INDEX IF NOT EXISTS "timeline_camera" ON "timeline" ("camera")'
migrator.sql('CREATE INDEX IF NOT EXISTS "timeline_source_id" ON "timeline" ("source_id")') )
migrator.sql(
'CREATE INDEX IF NOT EXISTS "timeline_source" ON "timeline" ("source")'
)
migrator.sql(
'CREATE INDEX IF NOT EXISTS "timeline_source_id" ON "timeline" ("source_id")'
)
def rollback(migrator, database, fake=False, **kwargs): def rollback(migrator, database, fake=False, **kwargs):

View File

@ -311,7 +311,6 @@ def process(path, label, output, debug_path):
for result in results: for result in results:
if count == 0: if count == 0:
# Writing headers of CSV file # Writing headers of CSV file
header = ["file"] + list(result[1].keys()) header = ["file"] + list(result[1].keys())
csv_writer.writerow(header) csv_writer.writerow(header)