From 69627fbe11d1c55689cdc190134142c3d5516ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Sat, 12 Jun 2021 12:04:38 +0200 Subject: [PATCH] fix: exclude zero entries --- models/summary.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/models/summary.go b/models/summary.go index 6619574..67c83d8 100644 --- a/models/summary.go +++ b/models/summary.go @@ -163,14 +163,18 @@ func (s *Summary) FillBy(fromType uint8, toType uint8) { break } } - if existingEntryIdx >= 0 { - (*typeItems[toType])[existingEntryIdx].Total = (totalWanted - totalActual) / time.Second // workaround - } else { - *typeItems[toType] = append(*typeItems[toType], &SummaryItem{ - Type: toType, - Key: key, - Total: (totalWanted - totalActual) / time.Second, // workaround - }) + + total := (totalWanted - totalActual) / time.Second // workaround + if total > 0 { + if existingEntryIdx >= 0 { + (*typeItems[toType])[existingEntryIdx].Total = total + } else { + *typeItems[toType] = append(*typeItems[toType], &SummaryItem{ + Type: toType, + Key: key, + Total: total, + }) + } } }