2022-04-16 18:40:04 +03:00
|
|
|
from peewee import (
|
2023-05-29 13:31:17 +03:00
|
|
|
BooleanField,
|
2022-04-16 18:40:04 +03:00
|
|
|
CharField,
|
|
|
|
|
DateTimeField,
|
|
|
|
|
FloatField,
|
|
|
|
|
IntegerField,
|
2023-05-29 13:31:17 +03:00
|
|
|
Model,
|
|
|
|
|
TextField,
|
2022-04-16 18:40:04 +03:00
|
|
|
)
|
2022-04-18 14:52:13 +03:00
|
|
|
from playhouse.sqlite_ext import JSONField
|
2020-11-01 17:06:15 +03:00
|
|
|
|
2020-11-04 15:31:25 +03:00
|
|
|
|
2022-04-16 18:40:04 +03:00
|
|
|
class Event(Model): # type: ignore[misc]
|
2020-11-01 17:06:15 +03:00
|
|
|
id = CharField(null=False, primary_key=True, max_length=30)
|
|
|
|
|
label = CharField(index=True, max_length=20)
|
2023-05-05 01:59:44 +03:00
|
|
|
sub_label = CharField(max_length=100, null=True)
|
2020-11-01 17:06:15 +03:00
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
|
start_time = DateTimeField()
|
|
|
|
|
end_time = DateTimeField()
|
2023-04-30 20:07:14 +03: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 17:06:15 +03:00
|
|
|
false_positive = BooleanField()
|
2020-11-04 15:31:25 +03:00
|
|
|
zones = JSONField()
|
2020-11-15 17:50:49 +03:00
|
|
|
thumbnail = TextField()
|
2020-12-24 16:47:27 +03:00
|
|
|
has_clip = BooleanField(default=True)
|
|
|
|
|
has_snapshot = BooleanField(default=True)
|
2023-04-30 20:07:14 +03: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 07:03:01 +03:00
|
|
|
retain_indefinitely = BooleanField(default=False)
|
2023-07-09 19:40:39 +03:00
|
|
|
ratio = FloatField(
|
|
|
|
|
default=1.0
|
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
2022-04-03 23:00:11 +03:00
|
|
|
plus_id = CharField(max_length=30)
|
2023-04-24 15:24:28 +03:00
|
|
|
model_hash = CharField(max_length=32)
|
|
|
|
|
detector_type = CharField(max_length=32)
|
|
|
|
|
model_type = CharField(max_length=32)
|
2023-04-30 20:07:14 +03:00
|
|
|
data = JSONField() # ex: tracked object box, region, etc.
|
2021-06-07 04:24:36 +03:00
|
|
|
|
|
|
|
|
|
2023-04-23 18:45:19 +03: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 02:21:52 +03: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 18:40:04 +03:00
|
|
|
class Recordings(Model): # type: ignore[misc]
|
2021-06-07 04:24:36 +03: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 22:47:59 +03:00
|
|
|
motion = IntegerField(null=True)
|
|
|
|
|
objects = IntegerField(null=True)
|
2023-07-15 03:05:14 +03:00
|
|
|
dBFS = IntegerField(null=True)
|
2022-10-09 14:28:26 +03:00
|
|
|
segment_size = FloatField(default=0) # this should be stored as MB
|
2024-03-15 18:29:22 +03:00
|
|
|
regions = IntegerField(null=True)
|
2023-06-11 16:01:50 +03:00
|
|
|
|
|
|
|
|
|
2024-04-20 01:11:41 +03: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 02:26:09 +03: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 17:16:01 +03: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 16:01:50 +03: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 19:36:13 +03: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)
|