Add support for stationary and active timeline entires (#7344)

* Add support for stationary and active timeline entires

* Be sure to update stored event data copy with stationary
This commit is contained in:
Nicolas Mowen
2023-07-31 20:43:48 -06:00
committed by GitHub
parent f57d21039e
commit b7ff6735f6
5 changed files with 122 additions and 54 deletions

View File

@@ -37,6 +37,14 @@ def should_update_db(prev_event: Event, current_event: Event) -> bool:
return False
def should_update_state(prev_event: Event, current_event: Event) -> bool:
"""If current event should update state, but not necessarily update the db."""
if prev_event["stationary"] != current_event["stationary"]:
return True
return False
class EventProcessor(threading.Thread):
def __init__(
self,
@@ -107,8 +115,11 @@ class EventProcessor(threading.Thread):
event_data: Event,
) -> None:
"""handle tracked object event updates."""
updated_db = False
# if this is the first message, just store it and continue, its not time to insert it in the db
if should_update_db(self.events_in_process[event_data["id"]], event_data):
updated_db = True
camera_config = self.config.cameras[camera]
event_config: EventsConfig = camera_config.record.events
width = camera_config.detect.width
@@ -210,6 +221,10 @@ class EventProcessor(threading.Thread):
.execute()
)
# check if the stored event_data should be updated
if updated_db or should_update_state(
self.events_in_process[event_data["id"]], event_data
):
# update the stored copy for comparison on future update messages
self.events_in_process[event_data["id"]] = event_data