Fix review item query

This commit is contained in:
Nicolas Mowen 2024-09-03 08:38:48 -06:00
parent 08c8c077d7
commit 72797e48e7

View File

@ -5,9 +5,11 @@ import itertools
import logging import logging
import os import os
import threading import threading
from functools import reduce
from multiprocessing.synchronize import Event as MpEvent from multiprocessing.synchronize import Event as MpEvent
from pathlib import Path from pathlib import Path
from peewee import operator
from playhouse.sqlite_ext import SqliteExtDatabase from playhouse.sqlite_ext import SqliteExtDatabase
from frigate.config import CameraConfig, FrigateConfig, RetainModeEnum from frigate.config import CameraConfig, FrigateConfig, RetainModeEnum
@ -71,17 +73,26 @@ class RecordingCleanup(threading.Thread):
).timestamp() ).timestamp()
expired_reviews: ReviewSegment = ( expired_reviews: ReviewSegment = (
ReviewSegment.select(ReviewSegment.id) ReviewSegment.select(ReviewSegment.id)
.where(ReviewSegment.camera == "front_cam")
.where( .where(
ReviewSegment.camera == config.name reduce(
and ( operator.or_,
( [
ReviewSegment.severity == "alert" reduce(
and ReviewSegment.end_time < alert_expire_date operator.and_,
) [
or ( (ReviewSegment.severity == "alert"),
ReviewSegment.severity == "detection" (ReviewSegment.end_time < alert_expire_date),
and ReviewSegment.end_time < detection_expire_date ],
) ),
reduce(
operator.and_,
[
(ReviewSegment.severity == "detection"),
(ReviewSegment.end_time < detection_expire_date),
],
),
],
) )
) )
.namedtuples() .namedtuples()