mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-22 20:18:30 +03:00
bug fix test failed
This commit is contained in:
parent
a523d1b7b0
commit
8d1a60fd33
@ -13,7 +13,7 @@ from peewee import (
|
|||||||
from playhouse.sqlite_ext import JSONField
|
from playhouse.sqlite_ext import JSONField
|
||||||
|
|
||||||
|
|
||||||
class Event(Model):
|
class Event(Model): # type: ignore[misc]
|
||||||
id = CharField(null=False, primary_key=True, max_length=30)
|
id = CharField(null=False, primary_key=True, max_length=30)
|
||||||
label = CharField(index=True, max_length=20)
|
label = CharField(index=True, max_length=20)
|
||||||
sub_label = CharField(max_length=100, null=True)
|
sub_label = CharField(max_length=100, null=True)
|
||||||
@ -51,7 +51,7 @@ class Event(Model):
|
|||||||
data = JSONField() # ex: tracked object box, region, etc.
|
data = JSONField() # ex: tracked object box, region, etc.
|
||||||
|
|
||||||
|
|
||||||
class Timeline(Model):
|
class Timeline(Model): # type: ignore[misc]
|
||||||
timestamp = DateTimeField()
|
timestamp = DateTimeField()
|
||||||
camera = CharField(index=True, max_length=20)
|
camera = CharField(index=True, max_length=20)
|
||||||
source = CharField(index=True, max_length=20) # ex: tracked object, audio, external
|
source = CharField(index=True, max_length=20) # ex: tracked object, audio, external
|
||||||
@ -60,13 +60,13 @@ class Timeline(Model):
|
|||||||
data = JSONField() # ex: tracked object id, region, box, etc.
|
data = JSONField() # ex: tracked object id, region, box, etc.
|
||||||
|
|
||||||
|
|
||||||
class Regions(Model):
|
class Regions(Model): # type: ignore[misc]
|
||||||
camera = CharField(null=False, primary_key=True, max_length=20)
|
camera = CharField(null=False, primary_key=True, max_length=20)
|
||||||
grid = JSONField() # json blob of grid
|
grid = JSONField() # json blob of grid
|
||||||
last_update = DateTimeField()
|
last_update = DateTimeField()
|
||||||
|
|
||||||
|
|
||||||
class Recordings(Model):
|
class Recordings(Model): # type: ignore[misc]
|
||||||
id = CharField(null=False, primary_key=True, max_length=30)
|
id = CharField(null=False, primary_key=True, max_length=30)
|
||||||
camera = CharField(index=True, max_length=20)
|
camera = CharField(index=True, max_length=20)
|
||||||
path = CharField(unique=True)
|
path = CharField(unique=True)
|
||||||
@ -80,7 +80,7 @@ class Recordings(Model):
|
|||||||
regions = IntegerField(null=True)
|
regions = IntegerField(null=True)
|
||||||
|
|
||||||
|
|
||||||
class Export(Model):
|
class Export(Model): # type: ignore[misc]
|
||||||
id = CharField(null=False, primary_key=True, max_length=30)
|
id = CharField(null=False, primary_key=True, max_length=30)
|
||||||
camera = CharField(index=True, max_length=20)
|
camera = CharField(index=True, max_length=20)
|
||||||
name = CharField(index=True, max_length=100)
|
name = CharField(index=True, max_length=100)
|
||||||
@ -90,7 +90,7 @@ class Export(Model):
|
|||||||
in_progress = BooleanField()
|
in_progress = BooleanField()
|
||||||
|
|
||||||
|
|
||||||
class ReviewSegment(Model):
|
class ReviewSegment(Model): # type: ignore[misc]
|
||||||
id = CharField(null=False, primary_key=True, max_length=30)
|
id = CharField(null=False, primary_key=True, max_length=30)
|
||||||
camera = CharField(index=True, max_length=20)
|
camera = CharField(index=True, max_length=20)
|
||||||
start_time = DateTimeField()
|
start_time = DateTimeField()
|
||||||
@ -100,7 +100,7 @@ class ReviewSegment(Model):
|
|||||||
data = JSONField() # additional data about detection like list of labels, zone, areas of significant motion
|
data = JSONField() # additional data about detection like list of labels, zone, areas of significant motion
|
||||||
|
|
||||||
|
|
||||||
class UserReviewStatus(Model):
|
class UserReviewStatus(Model): # type: ignore[misc]
|
||||||
user_id = CharField(max_length=30)
|
user_id = CharField(max_length=30)
|
||||||
review_segment = ForeignKeyField(ReviewSegment, backref="user_reviews")
|
review_segment = ForeignKeyField(ReviewSegment, backref="user_reviews")
|
||||||
has_been_reviewed = BooleanField(default=False)
|
has_been_reviewed = BooleanField(default=False)
|
||||||
@ -109,7 +109,7 @@ class UserReviewStatus(Model):
|
|||||||
indexes = ((("user_id", "review_segment"), True),)
|
indexes = ((("user_id", "review_segment"), True),)
|
||||||
|
|
||||||
|
|
||||||
class Previews(Model):
|
class Previews(Model): # type: ignore[misc]
|
||||||
id = CharField(null=False, primary_key=True, max_length=30)
|
id = CharField(null=False, primary_key=True, max_length=30)
|
||||||
camera = CharField(index=True, max_length=20)
|
camera = CharField(index=True, max_length=20)
|
||||||
path = CharField(unique=True)
|
path = CharField(unique=True)
|
||||||
@ -119,14 +119,14 @@ class Previews(Model):
|
|||||||
|
|
||||||
|
|
||||||
# Used for temporary table in record/cleanup.py
|
# Used for temporary table in record/cleanup.py
|
||||||
class RecordingsToDelete(Model):
|
class RecordingsToDelete(Model): # type: ignore[misc]
|
||||||
id = CharField(null=False, primary_key=False, max_length=30)
|
id = CharField(null=False, primary_key=False, max_length=30)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
temporary = True
|
temporary = True
|
||||||
|
|
||||||
|
|
||||||
class User(Model):
|
class User(Model): # type: ignore[misc]
|
||||||
username = CharField(null=False, primary_key=True, max_length=30)
|
username = CharField(null=False, primary_key=True, max_length=30)
|
||||||
role = CharField(
|
role = CharField(
|
||||||
max_length=20,
|
max_length=20,
|
||||||
@ -149,7 +149,7 @@ class User(Model):
|
|||||||
return [cam for cam in allowed if cam in all_camera_names]
|
return [cam for cam in allowed if cam in all_camera_names]
|
||||||
|
|
||||||
|
|
||||||
class Trigger(Model):
|
class Trigger(Model): # type: ignore[misc]
|
||||||
camera = CharField(max_length=20)
|
camera = CharField(max_length=20)
|
||||||
name = CharField()
|
name = CharField()
|
||||||
type = CharField(max_length=10)
|
type = CharField(max_length=10)
|
||||||
|
|||||||
@ -510,8 +510,12 @@ class TestHttpReview(BaseTestHttp):
|
|||||||
with AuthTestClient(self.app) as client:
|
with AuthTestClient(self.app) as client:
|
||||||
ids = ["123456.random", "654321.random"]
|
ids = ["123456.random", "654321.random"]
|
||||||
for id in ids:
|
for id in ids:
|
||||||
super().insert_mock_review_segment(id)
|
# Use the same timestamps for both review segment and recording
|
||||||
super().insert_mock_recording(id)
|
# to ensure they overlap so the delete endpoint can find the recording
|
||||||
|
start_time = datetime.now().timestamp()
|
||||||
|
end_time = start_time + 20
|
||||||
|
super().insert_mock_review_segment(id, start_time=start_time, end_time=end_time)
|
||||||
|
super().insert_mock_recording(id, start_time=start_time, end_time=end_time)
|
||||||
|
|
||||||
review_ids_in_db_before = self._get_reviews(ids)
|
review_ids_in_db_before = self._get_reviews(ids)
|
||||||
recordings_ids_in_db_before = self._get_recordings(ids)
|
recordings_ids_in_db_before = self._get_recordings(ids)
|
||||||
|
|||||||
@ -382,12 +382,12 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
tracked_obj.obj_data["sub_label"] = (sub_label, score)
|
tracked_obj.obj_data["sub_label"] = (sub_label, score)
|
||||||
|
|
||||||
if event:
|
if event:
|
||||||
event.sub_label = sub_label # type: ignore[assignment]
|
event.sub_label = sub_label
|
||||||
data = event.data
|
data = event.data
|
||||||
if sub_label is None:
|
if sub_label is None:
|
||||||
data["sub_label_score"] = None # type: ignore[index]
|
data["sub_label_score"] = None
|
||||||
elif score is not None:
|
elif score is not None:
|
||||||
data["sub_label_score"] = score # type: ignore[index]
|
data["sub_label_score"] = score
|
||||||
event.data = data
|
event.data = data
|
||||||
event.save()
|
event.save()
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
objects_list = []
|
objects_list = []
|
||||||
sub_labels = set()
|
sub_labels = set()
|
||||||
events = Event.select(Event.id, Event.label, Event.sub_label).where(
|
events = Event.select(Event.id, Event.label, Event.sub_label).where(
|
||||||
Event.id.in_(detection_ids) # type: ignore[call-arg, misc]
|
Event.id.in_(detection_ids)
|
||||||
)
|
)
|
||||||
for det_event in events:
|
for det_event in events:
|
||||||
if det_event.sub_label:
|
if det_event.sub_label:
|
||||||
@ -482,11 +482,11 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
|
|
||||||
if event:
|
if event:
|
||||||
data = event.data
|
data = event.data
|
||||||
data[field_name] = field_value # type: ignore[index]
|
data[field_name] = field_value
|
||||||
if field_value is None:
|
if field_value is None:
|
||||||
data[f"{field_name}_score"] = None # type: ignore[index]
|
data[f"{field_name}_score"] = None
|
||||||
elif score is not None:
|
elif score is not None:
|
||||||
data[f"{field_name}_score"] = score # type: ignore[index]
|
data[f"{field_name}_score"] = score
|
||||||
event.data = data
|
event.data = data
|
||||||
event.save()
|
event.save()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user