From 4613bde379969c619dd8958f8125727cc741ff57 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 3 Sep 2024 10:11:26 -0600 Subject: [PATCH] Simplify logic --- frigate/record/cleanup.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/frigate/record/cleanup.py b/frigate/record/cleanup.py index 060f6e33c..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 @@ -75,24 +73,15 @@ class RecordingCleanup(threading.Thread): ReviewSegment.select(ReviewSegment.id) .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()