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()