fix category count #2
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Arnas Udovic 2025-03-16 14:51:43 +02:00
parent e655ccfd40
commit 9220c37765

View file

@ -1,6 +1,7 @@
package main
import (
"fmt"
"strings"
zordTree "g.arns.lt/zordsdavini/zord-tree"
@ -17,8 +18,8 @@ func FormatTreeSummery(tree zordTree.Tree) Tree {
}
func readTree(tree zordTree.Tree, ts *Tree, isRoot bool) {
fmt.Println(ts.Categories, isRoot)
for _, subtree := range tree.Dirs {
readTree(subtree, ts, false)
category := strings.Replace(subtree.Path, tree.Path, "", 1)
category = strings.Replace(category, "/", "", 1)
if isRoot {
@ -26,7 +27,18 @@ func readTree(tree zordTree.Tree, ts *Tree, isRoot bool) {
ts.Categories = make(map[string]int32)
}
ts.Categories[category] = int32(len(subtree.Files))
} else {
if len(tree.Files) > 0 {
for _, subcategory := range tree.Files[0].Category {
if val, ok := ts.Categories[subcategory]; ok {
fmt.Println(val, ok, subcategory)
ts.Categories[subcategory] += int32(len(subtree.Files))
}
}
}
}
readTree(subtree, ts, false)
}
for _, file := range tree.Files {