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

This commit is contained in:
Arnas Udovic 2025-03-16 15:12:45 +02:00
parent 9220c37765
commit bc58aacccc

View file

@ -1,7 +1,6 @@
package main
import (
"fmt"
"strings"
zordTree "g.arns.lt/zordsdavini/zord-tree"
@ -18,7 +17,6 @@ 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 {
category := strings.Replace(subtree.Path, tree.Path, "", 1)
category = strings.Replace(category, "/", "", 1)
@ -28,12 +26,9 @@ func readTree(tree zordTree.Tree, ts *Tree, isRoot bool) {
}
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))
}
for _, subcategory := range subtree.Files[0].Category {
if _, ok := ts.Categories[subcategory]; ok {
ts.Categories[subcategory] += int32(len(subtree.Files))
}
}
}