Skip to content

Commit c035241

Browse files
authored
Clear ongoing reviews on startup (#11097)
* Add topic to clear ongoing review segments * Clear ongoing review items on startup
1 parent 313e7c0 commit c035241

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

frigate/comms/dispatcher.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
"""Handle communication between Frigate and other applications."""
22

3+
import datetime
34
import logging
45
from abc import ABC, abstractmethod
56
from typing import Any, Callable, Optional
67

78
from frigate.comms.config_updater import ConfigPublisher
89
from frigate.config import BirdseyeModeEnum, FrigateConfig
910
from frigate.const import (
11+
CLEAR_ONGOING_REVIEW_SEGMENTS,
1012
INSERT_MANY_RECORDINGS,
1113
INSERT_PREVIEW,
1214
REQUEST_REGION_GRID,
@@ -116,6 +118,10 @@ def _receive(self, topic: str, payload: str) -> Optional[Any]:
116118
)
117119
.execute()
118120
)
121+
elif topic == CLEAR_ONGOING_REVIEW_SEGMENTS:
122+
ReviewSegment.update(end_time=datetime.datetime.now().timestamp()).where(
123+
ReviewSegment.end_time == None
124+
).execute()
119125
else:
120126
self.publish(topic, payload, retain=False)
121127

frigate/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
INSERT_PREVIEW = "insert_preview"
8080
REQUEST_REGION_GRID = "request_region_grid"
8181
UPSERT_REVIEW_SEGMENT = "upsert_review_segment"
82+
CLEAR_ONGOING_REVIEW_SEGMENTS = "clear_ongoing_review_segments"
8283

8384
# Autotracking
8485

frigate/review/maintainer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
from frigate.comms.detections_updater import DetectionSubscriber, DetectionTypeEnum
2020
from frigate.comms.inter_process import InterProcessRequestor
2121
from frigate.config import CameraConfig, FrigateConfig
22-
from frigate.const import ALL_ATTRIBUTE_LABELS, CLIPS_DIR, UPSERT_REVIEW_SEGMENT
22+
from frigate.const import (
23+
ALL_ATTRIBUTE_LABELS,
24+
CLEAR_ONGOING_REVIEW_SEGMENTS,
25+
CLIPS_DIR,
26+
UPSERT_REVIEW_SEGMENT,
27+
)
2328
from frigate.events.external import ManualEventState
2429
from frigate.models import ReviewSegment
2530
from frigate.object_processing import TrackedObject
@@ -146,6 +151,9 @@ def __init__(self, config: FrigateConfig, stop_event: MpEvent):
146151

147152
self.stop_event = stop_event
148153

154+
# clear ongoing review segments from last instance
155+
self.requestor.send_data(CLEAR_ONGOING_REVIEW_SEGMENTS, "")
156+
149157
def new_segment(
150158
self,
151159
segment: PendingReviewSegment,

0 commit comments

Comments
 (0)