Catch case where camera has 0 nonzero segment durations

This commit is contained in:
Nick Mowen 2022-09-27 09:59:49 -06:00
parent 3af9929e1d
commit 0d4118f590

View File

@ -45,6 +45,7 @@ class StorageMaintainer(threading.Thread):
} }
# calculate MB/hr # calculate MB/hr
try:
bandwidth = round( bandwidth = round(
Recordings.select(fn.AVG(bandwidth_equation)) Recordings.select(fn.AVG(bandwidth_equation))
.where(Recordings.camera == camera, Recordings.segment_size != 0) .where(Recordings.camera == camera, Recordings.segment_size != 0)
@ -53,6 +54,9 @@ class StorageMaintainer(threading.Thread):
* 3600, * 3600,
2, 2,
) )
except TypeError:
bandwidth = 0
self.camera_storage_stats[camera]["bandwidth"] = bandwidth self.camera_storage_stats[camera]["bandwidth"] = bandwidth
logger.debug(f"{camera} has a bandwidth of {bandwidth} MB/hr.") logger.debug(f"{camera} has a bandwidth of {bandwidth} MB/hr.")