From b1d414b75c93e092e5b901c2146b18ba2427f8ca Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Sun, 16 Jul 2023 09:40:41 -0600 Subject: [PATCH] Fix logic --- frigate/record/maintainer.py | 14 ++++++-------- frigate/test/test_record_retention.py | 8 ++++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py index 90103743a..e1dabdf67 100644 --- a/frigate/record/maintainer.py +++ b/frigate/record/maintainer.py @@ -38,14 +38,12 @@ class SegmentInfo: def should_discard_segment(self, retain_mode: RetainModeEnum) -> bool: return ( - (retain_mode == RetainModeEnum.motion and self.motion_box_count == 0) - or ( - retain_mode == RetainModeEnum.motion and self.average_dBFS == 0 - ) # dBFS is stored in a negative scale - or ( - retain_mode == RetainModeEnum.active_objects - and self.active_object_count == 0 - ) + retain_mode == RetainModeEnum.motion + and self.motion_box_count == 0 + and self.average_dBFS == 0 + ) or ( + retain_mode == RetainModeEnum.active_objects + and self.active_object_count == 0 ) diff --git a/frigate/test/test_record_retention.py b/frigate/test/test_record_retention.py index cae27702b..dbe115791 100644 --- a/frigate/test/test_record_retention.py +++ b/frigate/test/test_record_retention.py @@ -5,27 +5,27 @@ from frigate.record.maintainer import SegmentInfo class TestRecordRetention(unittest.TestCase): - def test_motion_should_keep_motion_not_object(): + def test_motion_should_keep_motion_not_object(self): segment_info = SegmentInfo( motion_box_count=1, active_object_count=0, average_dBFS=0 ) assert not segment_info.should_discard_segment(RetainModeEnum.motion) assert segment_info.should_discard_segment(RetainModeEnum.active_objects) - def test_object_should_keep_object_not_motion(): + def test_object_should_keep_object_not_motion(self): segment_info = SegmentInfo( motion_box_count=0, active_object_count=1, average_dBFS=0 ) assert segment_info.should_discard_segment(RetainModeEnum.motion) assert not segment_info.should_discard_segment(RetainModeEnum.active_objects) - def test_all_should_keep_all(): + def test_all_should_keep_all(self): segment_info = SegmentInfo( motion_box_count=0, active_object_count=0, average_dBFS=0 ) assert not segment_info.should_discard_segment(RetainModeEnum.all) - def test_should_keep_audio_in_motion_mode(): + def test_should_keep_audio_in_motion_mode(self): segment_info = SegmentInfo( motion_box_count=0, active_object_count=0, average_dBFS=1 )