From 5be4186323cb193b27b0fcadbbca01f432be52ac Mon Sep 17 00:00:00 2001 From: Valentin Kuznetsov Date: Thu, 20 Oct 2022 11:02:49 +0200 Subject: [PATCH] Fix ratio in case when block_file_count is zero --- services/combined.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/combined.go b/services/combined.go index 1cff3bc..ce6dd68 100644 --- a/services/combined.go +++ b/services/combined.go @@ -484,7 +484,11 @@ func (LocalAPIs) Site4DatasetPct(dasquery dasql.DASQuery) []mongo.DASRecord { } ratio := float64(rec2num(row["block_present"])) / float64(rec2num(row["blocks"])) bc := fmt.Sprintf("%5.2f%%", 100*ratio) - ratio = float64(rec2num(row["available_file_count"])) / float64(rec2num(row["block_file_count"])) + if rec2num(row["block_file_count"]) != 0 { + ratio = float64(rec2num(row["available_file_count"])) / float64(rec2num(row["block_file_count"])) + } else { + ratio = 0 + } rf := fmt.Sprintf("%5.2f%%", 100*ratio) if utils.VERBOSE > 0 { if utils.WEBSERVER == 0 {