mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-13 14:45:25 +03:00
Update version and cleanup
This commit is contained in:
parent
0a3988ba73
commit
64f9c0e67f
@ -5,7 +5,7 @@ from multiprocessing.synchronize import Event as MpEvent
|
||||
from typing import Dict
|
||||
|
||||
from frigate.comms.events_updater import EventEndPublisher, EventUpdateSubscriber
|
||||
from frigate.config import EventsConfig, FrigateConfig
|
||||
from frigate.config import FrigateConfig
|
||||
from frigate.events.types import EventStateEnum, EventTypeEnum
|
||||
from frigate.models import Event
|
||||
from frigate.util.builtin import to_relative_box
|
||||
|
||||
@ -69,22 +69,27 @@ class RecordingCleanup(threading.Thread):
|
||||
detection_expire_date = (
|
||||
now - datetime.timedelta(days=config.record.detections.retain.days)
|
||||
).timestamp()
|
||||
expired_reviews: ReviewSegment = ReviewSegment.select(ReviewSegment.id).where(
|
||||
ReviewSegment.camera == config.name
|
||||
and (
|
||||
(
|
||||
ReviewSegment.severity == "alert"
|
||||
and ReviewSegment.end_time < alert_expire_date
|
||||
)
|
||||
or (
|
||||
ReviewSegment.severity == "detection"
|
||||
and ReviewSegment.end_time < detection_expire_date
|
||||
expired_reviews: ReviewSegment = (
|
||||
ReviewSegment.select(ReviewSegment.id)
|
||||
.where(
|
||||
ReviewSegment.camera == config.name
|
||||
and (
|
||||
(
|
||||
ReviewSegment.severity == "alert"
|
||||
and ReviewSegment.end_time < alert_expire_date
|
||||
)
|
||||
or (
|
||||
ReviewSegment.severity == "detection"
|
||||
and ReviewSegment.end_time < detection_expire_date
|
||||
)
|
||||
)
|
||||
)
|
||||
.namedtuples()
|
||||
)
|
||||
|
||||
max_deletes = 100000
|
||||
deleted_reviews_list = list(expired_reviews)
|
||||
deleted_reviews_list = list(map(lambda x: x[0], expired_reviews))
|
||||
logger.info(f"the list is {deleted_reviews_list}")
|
||||
for i in range(0, len(deleted_reviews_list), max_deletes):
|
||||
ReviewSegment.delete().where(
|
||||
ReviewSegment.id << deleted_reviews_list[i : i + max_deletes]
|
||||
|
||||
@ -11,7 +11,7 @@ from playhouse.sqliteq import SqliteQueueDatabase
|
||||
from setproctitle import setproctitle
|
||||
|
||||
from frigate.config import FrigateConfig
|
||||
from frigate.models import Event, Recordings
|
||||
from frigate.models import Recordings, ReviewSegment
|
||||
from frigate.record.maintainer import RecordingMaintainer
|
||||
from frigate.util.services import listen
|
||||
|
||||
@ -41,7 +41,7 @@ def manage_recordings(config: FrigateConfig) -> None:
|
||||
},
|
||||
timeout=max(60, 10 * len([c for c in config.cameras.values() if c.enabled])),
|
||||
)
|
||||
models = [Event, Recordings]
|
||||
models = [ReviewSegment, Recordings]
|
||||
db.bind(models)
|
||||
|
||||
maintainer = RecordingMaintainer(
|
||||
|
||||
@ -381,9 +381,7 @@ class TestConfig(unittest.TestCase):
|
||||
def test_motion_mask_relative_matches_explicit(self):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
},
|
||||
"record": {"alerts": {"retain": {"days": 20}}},
|
||||
"cameras": {
|
||||
"explicit": {
|
||||
"ffmpeg": {
|
||||
@ -581,7 +579,11 @@ class TestConfig(unittest.TestCase):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
"alerts": {
|
||||
"retain": {
|
||||
"days": 20,
|
||||
}
|
||||
}
|
||||
},
|
||||
"cameras": {
|
||||
"back": {
|
||||
@ -605,7 +607,11 @@ class TestConfig(unittest.TestCase):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
"alerts": {
|
||||
"retain": {
|
||||
"days": 20,
|
||||
}
|
||||
}
|
||||
},
|
||||
"cameras": {
|
||||
"back": {
|
||||
@ -629,7 +635,11 @@ class TestConfig(unittest.TestCase):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
"alerts": {
|
||||
"retain": {
|
||||
"days": 20,
|
||||
}
|
||||
}
|
||||
},
|
||||
"cameras": {
|
||||
"back": {
|
||||
@ -660,7 +670,11 @@ class TestConfig(unittest.TestCase):
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"record": {
|
||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
||||
"alerts": {
|
||||
"retain": {
|
||||
"days": 20,
|
||||
}
|
||||
}
|
||||
},
|
||||
"cameras": {
|
||||
"back": {
|
||||
|
||||
@ -13,7 +13,7 @@ from frigate.util.services import get_video_properties
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
CURRENT_CONFIG_VERSION = "0.14.1-0"
|
||||
CURRENT_CONFIG_VERSION = "0.15-0"
|
||||
|
||||
|
||||
def migrate_frigate_config(config_file: str):
|
||||
@ -55,12 +55,12 @@ def migrate_frigate_config(config_file: str):
|
||||
os.path.join(EXPORT_DIR, file), os.path.join(EXPORT_DIR, new_name)
|
||||
)
|
||||
|
||||
if previous_version < "0.14.1-0":
|
||||
logger.info(f"Migrating frigate config from {previous_version} to 0.14.1-0...")
|
||||
new_config = migrate_0141_0(config)
|
||||
if previous_version < "0.15-0":
|
||||
logger.info(f"Migrating frigate config from {previous_version} to 0.15-0...")
|
||||
new_config = migrate_015_0(config)
|
||||
with open(config_file, "w") as f:
|
||||
yaml.dump(new_config, f)
|
||||
previous_version = "0.14.1-0"
|
||||
previous_version = "0.15-0"
|
||||
|
||||
logger.info("Finished frigate config migration...")
|
||||
|
||||
@ -152,8 +152,8 @@ def migrate_014(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
|
||||
return new_config
|
||||
|
||||
|
||||
def migrate_0141_0(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
|
||||
"""Handle migrating frigate config to 0.14.1-0"""
|
||||
def migrate_015_0(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
|
||||
"""Handle migrating frigate config to 0.15-0"""
|
||||
new_config = config.copy()
|
||||
|
||||
# migrate record.events to record.alerts and record.detections
|
||||
@ -240,7 +240,7 @@ def migrate_0141_0(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any
|
||||
|
||||
new_config["cameras"][name] = camera_config
|
||||
|
||||
new_config["version"] = "0.14.1-0"
|
||||
new_config["version"] = "0.15-0"
|
||||
return new_config
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user