From cd19b611f0e0abc9dfc167c9e2933be29ad0ba54 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Thu, 20 Apr 2023 14:12:29 -0600 Subject: [PATCH] Add other fields --- frigate/app.py | 4 ++-- frigate/models.py | 4 ++++ migrations/013_create_timeline_table.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index ef77cd1dd..d6a9ce61f 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -23,7 +23,7 @@ from frigate.object_detection import ObjectDetectProcess from frigate.events import EventCleanup, EventProcessor from frigate.http import create_app from frigate.log import log_process, root_configurer -from frigate.models import Event, Recordings +from frigate.models import Event, Recordings, Timeline from frigate.object_processing import TrackedObjectProcessor from frigate.output import output_frames from frigate.plus import PlusApi @@ -154,7 +154,7 @@ class FrigateApp: migrate_db.close() self.db = SqliteQueueDatabase(self.config.database.path) - models = [Event, Recordings] + models = [Event, Recordings, Timeline] self.db.bind(models) def init_stats(self) -> None: diff --git a/frigate/models.py b/frigate/models.py index e82da20d7..fa4ba0478 100644 --- a/frigate/models.py +++ b/frigate/models.py @@ -38,7 +38,11 @@ class Timeline(Model): # type: ignore[misc] input_type = CharField(index=True, max_length=20) # ex: object, audio, external detection_type = CharField(max_length=50) # ex: entered_front_yard, heard_dog_barking timestamp = DateTimeField() + + # event-only fields event_id = CharField() + region = JSONField() + box = JSONField() class Recordings(Model): # type: ignore[misc] diff --git a/migrations/013_create_timeline_table.py b/migrations/013_create_timeline_table.py index bd02f6cdf..23e8bce7d 100644 --- a/migrations/013_create_timeline_table.py +++ b/migrations/013_create_timeline_table.py @@ -37,7 +37,7 @@ SQL = pw.SQL def migrate(migrator, database, fake=False, **kwargs): migrator.sql( - 'CREATE TABLE IF NOT EXISTS "timeline" ("id" VARCHAR(30) NOT NULL PRIMARY KEY, "camera" VARCHAR(20) NOT NULL, "input_type" VARCHAR(20) NOT NULL, "detection_type" VARCHAR(50) NOT NULL, "timestamp" DATETIME NOT NULL, "event_id" VARCHAR(30))' + 'CREATE TABLE IF NOT EXISTS "timeline" ("id" VARCHAR(30) NOT NULL PRIMARY KEY, "camera" VARCHAR(20) NOT NULL, "input_type" VARCHAR(20) NOT NULL, "detection_type" VARCHAR(50) NOT NULL, "timestamp" DATETIME NOT NULL, "event_id" VARCHAR(30), "region" JSON, "box" JSON)' ) migrator.sql('CREATE INDEX IF NOT EXISTS "timeline_camera" ON "timeline" ("camera")') migrator.sql('CREATE INDEX IF NOT EXISTS "timeline_input_type" ON "timeline" ("input_type")')