allow partial days in retention settings

This commit is contained in:
Blake Blackshear 2021-09-20 18:59:16 -05:00
parent a943ac1308
commit c3109f808c
2 changed files with 27 additions and 3 deletions

View File

@ -66,8 +66,8 @@ class MqttConfig(FrigateBaseModel):
class RetainConfig(FrigateBaseModel):
default: int = Field(default=10, title="Default retention period.")
objects: Dict[str, int] = Field(
default: float = Field(default=10, title="Default retention period.")
objects: Dict[str, float] = Field(
default_factory=dict, title="Object retention period."
)
@ -90,7 +90,7 @@ class EventsConfig(FrigateBaseModel):
class RecordConfig(FrigateBaseModel):
enabled: bool = Field(default=False, title="Enable record on all cameras.")
retain_days: int = Field(default=0, title="Recording retention period in days.")
retain_days: float = Field(default=0, title="Recording retention period in days.")
events: EventsConfig = Field(
default_factory=EventsConfig, title="Event specific settings."
)

View File

@ -1107,6 +1107,30 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].timestamp_style.position == "bl"
assert runtime_config.cameras["back"].timestamp_style.thickness == 4
def test_allow_retain_to_be_a_decimal(self):
config = {
"mqtt": {"host": "mqtt"},
"snapshots": {"retain": {"default": 1.5}},
"cameras": {
"back": {
"ffmpeg": {
"inputs": [
{
"path": "rtsp://10.0.0.1:554/video",
"roles": ["detect"],
},
]
},
}
},
}
frigate_config = FrigateConfig(**config)
assert config == frigate_config.dict(exclude_unset=True)
runtime_config = frigate_config.runtime_config
assert runtime_config.cameras["back"].snapshots.retain.default == 1.5
if __name__ == "__main__":
unittest.main(verbosity=2)