From 10184061696d4817c92602e7c8684866cd8e1ac7 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 16 May 2021 14:23:02 +0800 Subject: [PATCH] Added counter for current day --- main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 7621065..1578e2d 100644 --- a/main.go +++ b/main.go @@ -131,14 +131,20 @@ func main() { } else if strings.HasSuffix(caption, "3") && caption != "13" { dayUnit = "rd" } - captionText += caption + dayUnit + " " + captionText += caption + dayUnit + " " + } + todayCounter := 1 + todayCounterBytes, errorObject := okDatabase.Get([]byte("DAY." + strconv.Itoa(currentDay))) + if errorObject == nil { + todayCounterInt64, _ := strconv.ParseInt(string(todayCounterBytes), 10, 0) + todayCounter = int(todayCounterInt64) } graph := "Not enough data..." heatmapOutput = heatmapOutput[:len(heatmapOutput)-2] if len(numberArray) > 0 { - graph = asciigraph.Plot(numberArray, asciigraph.Width(14), asciigraph.Height(10), asciigraph.Caption(captionText)) + graph = asciigraph.Plot(numberArray, asciigraph.Width(20), asciigraph.Height(10), asciigraph.Caption(captionText)) } - color.Printf("OK Counter: %v\nRecords: %v\nGraph:\n%v\n", currentCount, heatmapOutput, graph) + color.Printf("OK Counter: %v\nRecords: %v\nGraph:\n%v\n\nYou've said OK %v times today\n", currentCount, heatmapOutput, graph, todayCounter) } else if resetValues { scanner := bufio.NewScanner(os.Stdin) color.Danger.Println("Are you sure you want to reset all values?")