2022-04-16 17:40:04 +02:00
|
|
|
from peewee import (
|
2023-05-29 12:31:17 +02:00
|
|
|
BooleanField,
|
2022-04-16 17:40:04 +02:00
|
|
|
CharField,
|
|
|
|
DateTimeField,
|
|
|
|
FloatField,
|
|
|
|
IntegerField,
|
2023-05-29 12:31:17 +02:00
|
|
|
Model,
|
|
|
|
TextField,
|
2022-04-16 17:40:04 +02:00
|
|
|
)
|
2022-04-18 13:52:13 +02:00
|
|
|
from playhouse.sqlite_ext import JSONField
|
2020-11-01 15:06:15 +01:00
|
|
|
|
2020-11-04 13:31:25 +01:00
|
|
|
|
2022-04-16 17:40:04 +02:00
|
|
|
class Event(Model): # type: ignore[misc]
|
2020-11-01 15:06:15 +01:00
|
|
|
id = CharField(null=False, primary_key=True, max_length=30)
|
|
|
|
label = CharField(index=True, max_length=20)
|
2023-05-05 00:59:44 +02:00
|
|
|
sub_label = CharField(max_length=100, null=True)
|
2020-11-01 15:06:15 +01:00
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
start_time = DateTimeField()
|
|
|
|
end_time = DateTimeField()
|
2023-04-30 19:07:14 +02:00
|
|
|
top_score = (
|
|
|
|
FloatField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
|
|
|
score = (
|
|
|
|
FloatField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
2020-11-01 15:06:15 +01:00
|
|
|
false_positive = BooleanField()
|
2020-11-04 13:31:25 +01:00
|
|
|
zones = JSONField()
|
2020-11-15 15:50:49 +01:00
|
|
|
thumbnail = TextField()
|
2020-12-24 14:47:27 +01:00
|
|
|
has_clip = BooleanField(default=True)
|
|
|
|
has_snapshot = BooleanField(default=True)
|
2023-04-30 19:07:14 +02:00
|
|
|
region = (
|
|
|
|
JSONField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
|
|
|
box = (
|
|
|
|
JSONField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
|
|
|
area = (
|
|
|
|
IntegerField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
2022-02-22 05:03:01 +01:00
|
|
|
retain_indefinitely = BooleanField(default=False)
|
2023-07-09 18:40:39 +02:00
|
|
|
ratio = FloatField(
|
|
|
|
default=1.0
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
2022-04-03 22:00:11 +02:00
|
|
|
plus_id = CharField(max_length=30)
|
2023-04-24 14:24:28 +02:00
|
|
|
model_hash = CharField(max_length=32)
|
|
|
|
detector_type = CharField(max_length=32)
|
|
|
|
model_type = CharField(max_length=32)
|
2023-04-30 19:07:14 +02:00
|
|
|
data = JSONField() # ex: tracked object box, region, etc.
|
2021-06-07 03:24:36 +02:00
|
|
|
|
|
|
|
|
2023-04-23 17:45:19 +02:00
|
|
|
class Timeline(Model): # type: ignore[misc]
|
|
|
|
timestamp = DateTimeField()
|
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
source = CharField(index=True, max_length=20) # ex: tracked object, audio, external
|
|
|
|
source_id = CharField(index=True, max_length=30)
|
|
|
|
class_type = CharField(max_length=50) # ex: entered_zone, audio_heard
|
|
|
|
data = JSONField() # ex: tracked object id, region, box, etc.
|
|
|
|
|
|
|
|
|
2023-10-19 01:21:52 +02:00
|
|
|
class Regions(Model): # type: ignore[misc]
|
|
|
|
camera = CharField(null=False, primary_key=True, max_length=20)
|
|
|
|
grid = JSONField() # json blob of grid
|
|
|
|
last_update = DateTimeField()
|
|
|
|
|
|
|
|
|
2022-04-16 17:40:04 +02:00
|
|
|
class Recordings(Model): # type: ignore[misc]
|
2021-06-07 03:24:36 +02:00
|
|
|
id = CharField(null=False, primary_key=True, max_length=30)
|
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
path = CharField(unique=True)
|
|
|
|
start_time = DateTimeField()
|
|
|
|
end_time = DateTimeField()
|
|
|
|
duration = FloatField()
|
2021-12-11 20:47:59 +01:00
|
|
|
motion = IntegerField(null=True)
|
|
|
|
objects = IntegerField(null=True)
|
2023-07-15 02:05:14 +02:00
|
|
|
dBFS = IntegerField(null=True)
|
2022-10-09 13:28:26 +02:00
|
|
|
segment_size = FloatField(default=0) # this should be stored as MB
|
2024-03-15 16:29:22 +01:00
|
|
|
regions = IntegerField(null=True)
|
2023-06-11 15:01:50 +02:00
|
|
|
|
|
|
|
|
2024-04-20 00:11:41 +02:00
|
|
|
class Export(Model): # type: ignore[misc]
|
|
|
|
id = CharField(null=False, primary_key=True, max_length=30)
|
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
name = CharField(index=True, max_length=100)
|
|
|
|
date = DateTimeField()
|
|
|
|
video_path = CharField(unique=True)
|
|
|
|
thumb_path = CharField(unique=True)
|
|
|
|
in_progress = BooleanField()
|
|
|
|
|
|
|
|
|
2024-02-21 00:26:09 +01:00
|
|
|
class ReviewSegment(Model): # type: ignore[misc]
|
|
|
|
id = CharField(null=False, primary_key=True, max_length=30)
|
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
start_time = DateTimeField()
|
|
|
|
end_time = DateTimeField()
|
|
|
|
has_been_reviewed = BooleanField(default=False)
|
|
|
|
severity = CharField(max_length=30) # alert, detection, significant_motion
|
|
|
|
thumb_path = CharField(unique=True)
|
|
|
|
data = JSONField() # additional data about detection like list of labels, zone, areas of significant motion
|
|
|
|
|
|
|
|
|
2023-12-03 15:16:01 +01:00
|
|
|
class Previews(Model): # type: ignore[misc]
|
|
|
|
id = CharField(null=False, primary_key=True, max_length=30)
|
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
path = CharField(unique=True)
|
|
|
|
start_time = DateTimeField()
|
|
|
|
end_time = DateTimeField()
|
|
|
|
duration = FloatField()
|
|
|
|
|
|
|
|
|
2023-06-11 15:01:50 +02:00
|
|
|
# Used for temporary table in record/cleanup.py
|
|
|
|
class RecordingsToDelete(Model): # type: ignore[misc]
|
|
|
|
id = CharField(null=False, primary_key=False, max_length=30)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
temporary = True
|
2024-05-18 18:36:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
class User(Model): # type: ignore[misc]
|
|
|
|
username = CharField(null=False, primary_key=True, max_length=30)
|
|
|
|
password_hash = CharField(null=False, max_length=120)
|