From 58a471e4661602eccf5ec31ac015672418f8853d Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 3 Sep 2024 10:14:30 -0600 Subject: [PATCH] Fix hardcoded camera name (#13520) * Fix hardcoded camera name * Simplify logic --- frigate/record/cleanup.py | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/frigate/record/cleanup.py b/frigate/record/cleanup.py index 7703da8ea..9ac7f7f91 100644 --- a/frigate/record/cleanup.py +++ b/frigate/record/cleanup.py @@ -5,11 +5,9 @@ import itertools import logging import os import threading -from functools import reduce from multiprocessing.synchronize import Event as MpEvent from pathlib import Path -from peewee import operator from playhouse.sqlite_ext import SqliteExtDatabase from frigate.config import CameraConfig, FrigateConfig, RetainModeEnum @@ -73,26 +71,17 @@ class RecordingCleanup(threading.Thread): ).timestamp() expired_reviews: ReviewSegment = ( ReviewSegment.select(ReviewSegment.id) - .where(ReviewSegment.camera == "front_cam") + .where(ReviewSegment.camera == config.name) .where( - reduce( - operator.or_, - [ - reduce( - operator.and_, - [ - (ReviewSegment.severity == "alert"), - (ReviewSegment.end_time < alert_expire_date), - ], - ), - reduce( - operator.and_, - [ - (ReviewSegment.severity == "detection"), - (ReviewSegment.end_time < detection_expire_date), - ], - ), - ], + ( + ReviewSegment.severity + == "alert" & ReviewSegment.end_time + < alert_expire_date + ) + | ( + ReviewSegment.severity + == "detection" & ReviewSegment.end_time + < detection_expire_date ) ) .namedtuples()