From 551a012fdaa19e8ee620c6154680e1b4eee540bc Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Sun, 9 Aug 2020 15:48:08 +1000 Subject: [PATCH] make the badge expires in a mintue to make the stats more accurate --- main.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 5698070..92b282c 100644 --- a/main.go +++ b/main.go @@ -22,14 +22,13 @@ import ( ) const ( - // backgroundImageFilename = "images/bg.png" radius = 0 fontSize = 12 textMarginX = 6.0 textMarginY = 14 badgeHeight = 20 textStyle = "text-anchor:start;font-size:12px;fill:white;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;" - badgeExpireSeconds = 120 + badgeExpireSeconds = 60 labelWidthPortion = 0.65 ColorSchemeGreen = "fill-opacity:1.00; fill:rgb(49, 197, 83);" ColorSchemeOrange = "fill-opacity:1.00; fill:rgb(255, 87, 34);" @@ -137,7 +136,7 @@ func generateSVG(client api.Client, c *gin.Context) error { if metricValue > 10000 && metricValue < 1000000 { valueRectWidth = 50 - }else if metricValue >= 1000000 { + } else if metricValue >= 1000000 { valueRectWidth = 66 } badgeWidth := labelContainerWidth + valueRectWidth @@ -153,14 +152,12 @@ func generateSVG(client api.Client, c *gin.Context) error { canvas.Rect(0, 0, int(labelContainerWidth), badgeHeight, string(query.Color)) - //when there is metric label then use default label if len(query.ValueField) == 0 { label = query.Label } canvas.Text(textMarginX, textMarginY, label, textStyle) - valueText := strconv.Itoa(metricValue) canvas.Text(labelContainerWidth+textMarginX, textMarginY, valueText, textStyle) canvas.End()