2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-08-24 14:48:40 +08:00

fix: CurrentState without processed/failed data

This commit is contained in:
Ken Hibino
2019-12-25 21:29:20 -08:00
parent 9b87f7c1f1
commit fb24d158ae
3 changed files with 75 additions and 23 deletions

View File

@@ -84,7 +84,13 @@ func printStats(s *rdb.Stats) {
tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0)
fmt.Fprintf(tw, format, "Processed", "Failed", "Error Rate")
fmt.Fprintf(tw, format, "---------", "------", "----------")
fmt.Fprintf(tw, format, s.Processed, s.Failed, fmt.Sprintf("%.2f%%", float64(s.Failed)/float64(s.Processed)*100))
var errrate string
if s.Processed == 0 {
errrate = "N/A"
} else {
errrate = fmt.Sprintf("%.2f%%", float64(s.Failed)/float64(s.Processed)*100)
}
fmt.Fprintf(tw, format, s.Processed, s.Failed, errrate)
tw.Flush()
}