mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Clear ongoing reviews on startup (#11097)
* Add topic to clear ongoing review segments * Clear ongoing review items on startup
This commit is contained in:
parent
313e7c016c
commit
c035241b39
@ -1,5 +1,6 @@
|
|||||||
"""Handle communication between Frigate and other applications."""
|
"""Handle communication between Frigate and other applications."""
|
||||||
|
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Any, Callable, Optional
|
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.comms.config_updater import ConfigPublisher
|
||||||
from frigate.config import BirdseyeModeEnum, FrigateConfig
|
from frigate.config import BirdseyeModeEnum, FrigateConfig
|
||||||
from frigate.const import (
|
from frigate.const import (
|
||||||
|
CLEAR_ONGOING_REVIEW_SEGMENTS,
|
||||||
INSERT_MANY_RECORDINGS,
|
INSERT_MANY_RECORDINGS,
|
||||||
INSERT_PREVIEW,
|
INSERT_PREVIEW,
|
||||||
REQUEST_REGION_GRID,
|
REQUEST_REGION_GRID,
|
||||||
@ -116,6 +118,10 @@ class Dispatcher:
|
|||||||
)
|
)
|
||||||
.execute()
|
.execute()
|
||||||
)
|
)
|
||||||
|
elif topic == CLEAR_ONGOING_REVIEW_SEGMENTS:
|
||||||
|
ReviewSegment.update(end_time=datetime.datetime.now().timestamp()).where(
|
||||||
|
ReviewSegment.end_time == None
|
||||||
|
).execute()
|
||||||
else:
|
else:
|
||||||
self.publish(topic, payload, retain=False)
|
self.publish(topic, payload, retain=False)
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ INSERT_MANY_RECORDINGS = "insert_many_recordings"
|
|||||||
INSERT_PREVIEW = "insert_preview"
|
INSERT_PREVIEW = "insert_preview"
|
||||||
REQUEST_REGION_GRID = "request_region_grid"
|
REQUEST_REGION_GRID = "request_region_grid"
|
||||||
UPSERT_REVIEW_SEGMENT = "upsert_review_segment"
|
UPSERT_REVIEW_SEGMENT = "upsert_review_segment"
|
||||||
|
CLEAR_ONGOING_REVIEW_SEGMENTS = "clear_ongoing_review_segments"
|
||||||
|
|
||||||
# Autotracking
|
# Autotracking
|
||||||
|
|
||||||
|
@ -19,7 +19,12 @@ from frigate.comms.config_updater import ConfigSubscriber
|
|||||||
from frigate.comms.detections_updater import DetectionSubscriber, DetectionTypeEnum
|
from frigate.comms.detections_updater import DetectionSubscriber, DetectionTypeEnum
|
||||||
from frigate.comms.inter_process import InterProcessRequestor
|
from frigate.comms.inter_process import InterProcessRequestor
|
||||||
from frigate.config import CameraConfig, FrigateConfig
|
from frigate.config import CameraConfig, FrigateConfig
|
||||||
from frigate.const import ALL_ATTRIBUTE_LABELS, CLIPS_DIR, UPSERT_REVIEW_SEGMENT
|
from frigate.const import (
|
||||||
|
ALL_ATTRIBUTE_LABELS,
|
||||||
|
CLEAR_ONGOING_REVIEW_SEGMENTS,
|
||||||
|
CLIPS_DIR,
|
||||||
|
UPSERT_REVIEW_SEGMENT,
|
||||||
|
)
|
||||||
from frigate.events.external import ManualEventState
|
from frigate.events.external import ManualEventState
|
||||||
from frigate.models import ReviewSegment
|
from frigate.models import ReviewSegment
|
||||||
from frigate.object_processing import TrackedObject
|
from frigate.object_processing import TrackedObject
|
||||||
@ -146,6 +151,9 @@ class ReviewSegmentMaintainer(threading.Thread):
|
|||||||
|
|
||||||
self.stop_event = stop_event
|
self.stop_event = stop_event
|
||||||
|
|
||||||
|
# clear ongoing review segments from last instance
|
||||||
|
self.requestor.send_data(CLEAR_ONGOING_REVIEW_SEGMENTS, "")
|
||||||
|
|
||||||
def new_segment(
|
def new_segment(
|
||||||
self,
|
self,
|
||||||
segment: PendingReviewSegment,
|
segment: PendingReviewSegment,
|
||||||
|
Loading…
Reference in New Issue
Block a user