Add other fields

This commit is contained in:
Nick Mowen 2023-04-20 14:12:29 -06:00
parent 616566a8f9
commit cd19b611f0
3 changed files with 7 additions and 3 deletions

View File

@ -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:

View File

@ -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]

View File

@ -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")')