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,14 +45,18 @@ class StorageMaintainer(threading.Thread):
}
# calculate MB/hr
bandwidth = round(
Recordings.select(fn.AVG(bandwidth_equation))
.where(Recordings.camera == camera, Recordings.segment_size != 0)
.limit(100)
.scalar()
* 3600,
2,
)
try:
bandwidth = round(
Recordings.select(fn.AVG(bandwidth_equation))
.where(Recordings.camera == camera, Recordings.segment_size != 0)
.limit(100)
.scalar()
* 3600,
2,
)
except TypeError:
bandwidth = 0
self.camera_storage_stats[camera]["bandwidth"] = bandwidth
logger.debug(f"{camera} has a bandwidth of {bandwidth} MB/hr.")