Cleanup handling of first object message (#15480)

This commit is contained in:
Nicolas Mowen 2024-12-12 21:22:47 -06:00 committed by GitHub
parent d302b6e198
commit f336a91fee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -82,18 +82,23 @@ class EventProcessor(threading.Thread):
) )
if source_type == EventTypeEnum.tracked_object: if source_type == EventTypeEnum.tracked_object:
id = event_data["id"]
self.timeline_queue.put( self.timeline_queue.put(
( (
camera, camera,
source_type, source_type,
event_type, event_type,
self.events_in_process.get(event_data["id"]), self.events_in_process.get(id),
event_data, event_data,
) )
) )
if event_type == EventStateEnum.start: # if this is the first message, just store it and continue, its not time to insert it in the db
self.events_in_process[event_data["id"]] = event_data if (
event_type == EventStateEnum.start
or id not in self.events_in_process
):
self.events_in_process[id] = event_data
continue continue
self.handle_object_detection(event_type, camera, event_data) self.handle_object_detection(event_type, camera, event_data)
@ -123,10 +128,6 @@ class EventProcessor(threading.Thread):
"""handle tracked object event updates.""" """handle tracked object event updates."""
updated_db = False updated_db = False
# if this is the first message, just store it and continue, its not time to insert it in the db
if event_type == EventStateEnum.start:
self.events_in_process[event_data["id"]] = event_data
if should_update_db(self.events_in_process[event_data["id"]], event_data): if should_update_db(self.events_in_process[event_data["id"]], event_data):
updated_db = True updated_db = True
camera_config = self.config.cameras[camera] camera_config = self.config.cameras[camera]