From 24327c0d0c83357ecc06b2d1e47f29436b80dfa7 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Wed, 24 Apr 2024 07:20:00 -0600 Subject: [PATCH] Add topic to clear ongoing review segments --- frigate/comms/dispatcher.py | 6 ++++++ frigate/const.py | 1 + 2 files changed, 7 insertions(+) diff --git a/frigate/comms/dispatcher.py b/frigate/comms/dispatcher.py index 0b466a01c..6fc3885e0 100644 --- a/frigate/comms/dispatcher.py +++ b/frigate/comms/dispatcher.py @@ -1,5 +1,6 @@ """Handle communication between Frigate and other applications.""" +import datetime import logging from abc import ABC, abstractmethod from typing import Any, Callable, Optional @@ -7,6 +8,7 @@ from typing import Any, Callable, Optional from frigate.comms.config_updater import ConfigPublisher from frigate.config import BirdseyeModeEnum, FrigateConfig from frigate.const import ( + CLEAR_ONGOING_REVIEW_SEGMENTS, INSERT_MANY_RECORDINGS, INSERT_PREVIEW, REQUEST_REGION_GRID, @@ -116,6 +118,10 @@ class Dispatcher: ) .execute() ) + elif topic == CLEAR_ONGOING_REVIEW_SEGMENTS: + ReviewSegment.update(end_time=datetime.datetime.now().timestamp()).where( + ReviewSegment.end_time == None + ).execute() else: self.publish(topic, payload, retain=False) diff --git a/frigate/const.py b/frigate/const.py index 28ab83c8a..168d880fb 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -79,6 +79,7 @@ INSERT_MANY_RECORDINGS = "insert_many_recordings" INSERT_PREVIEW = "insert_preview" REQUEST_REGION_GRID = "request_region_grid" UPSERT_REVIEW_SEGMENT = "upsert_review_segment" +CLEAR_ONGOING_REVIEW_SEGMENTS = "clear_ongoing_review_segments" # Autotracking