Skip to content

Commit

Permalink
Fix ratio in case when block_file_count is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Oct 20, 2022
1 parent 54f9af8 commit 5be4186
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion services/combined.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5be4186

Please sign in to comment.