From 72797e48e759f866b1a661a02cd89b697d5eaef7 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 3 Sep 2024 08:38:48 -0600 Subject: [PATCH] Fix review item query --- frigate/record/cleanup.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/frigate/record/cleanup.py b/frigate/record/cleanup.py index 23fa45522..7703da8ea 100644 --- a/frigate/record/cleanup.py +++ b/frigate/record/cleanup.py @@ -5,9 +5,11 @@ 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 @@ -71,17 +73,26 @@ class RecordingCleanup(threading.Thread): ).timestamp() expired_reviews: ReviewSegment = ( ReviewSegment.select(ReviewSegment.id) + .where(ReviewSegment.camera == "front_cam") .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 - ) + 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), + ], + ), + ], ) ) .namedtuples()