From 750821a9c15ec0750f1b198aefa6c1ac36f608b9 Mon Sep 17 00:00:00 2001 From: Aurelio Ogliari Date: Sat, 31 Oct 2020 23:26:48 +0100 Subject: [PATCH 1/2] [feat] add stats --- _repoUtils/main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/_repoUtils/main.go b/_repoUtils/main.go index a92f0be..153c472 100644 --- a/_repoUtils/main.go +++ b/_repoUtils/main.go @@ -56,11 +56,13 @@ func prettyPrintResults(data *map[string]int) { func generateFile(dirStats *map[string]int) { type Entry struct { - Topic string - Count int + Topic string + Count int + Percentage int } - entries := make([]Entry, 0, len(*dirStats)) + total := len(*dirStats) + entries := make([]Entry, 0, total) for k, v := range *dirStats { topic := strings.ReplaceAll(strings.Title(k), "-", " ") @@ -68,6 +70,7 @@ func generateFile(dirStats *map[string]int) { entries = append(entries, entry) } sort.SliceStable(entries, func(i, j int) bool { + entries[i].Percentage = 5 return entries[i].Count > entries[j].Count }) @@ -102,6 +105,7 @@ func main() { scanner := bufio.NewScanner(r) var filePaths [][]byte + // { "go": 1433, "kubernetes": 5} dirStats := make(map[string]int) // This gets the oldest commit we want to analyse from From daa62d81195d2e2a103dfd7b7e1b8bc22c460f5a Mon Sep 17 00:00:00 2001 From: Aurelio Ogliari Date: Sat, 31 Oct 2020 23:27:47 +0100 Subject: [PATCH 2/2] [feat] add stats --- _repoUtils/main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/_repoUtils/main.go b/_repoUtils/main.go index 153c472..163cc55 100644 --- a/_repoUtils/main.go +++ b/_repoUtils/main.go @@ -105,7 +105,6 @@ func main() { scanner := bufio.NewScanner(r) var filePaths [][]byte - // { "go": 1433, "kubernetes": 5} dirStats := make(map[string]int) // This gets the oldest commit we want to analyse from