fix category count #2
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e655ccfd40
commit
9220c37765
1 changed files with 13 additions and 1 deletions
14
formatter.go
14
formatter.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
zordTree "g.arns.lt/zordsdavini/zord-tree"
|
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) {
|
func readTree(tree zordTree.Tree, ts *Tree, isRoot bool) {
|
||||||
|
fmt.Println(ts.Categories, isRoot)
|
||||||
for _, subtree := range tree.Dirs {
|
for _, subtree := range tree.Dirs {
|
||||||
readTree(subtree, ts, false)
|
|
||||||
category := strings.Replace(subtree.Path, tree.Path, "", 1)
|
category := strings.Replace(subtree.Path, tree.Path, "", 1)
|
||||||
category = strings.Replace(category, "/", "", 1)
|
category = strings.Replace(category, "/", "", 1)
|
||||||
if isRoot {
|
if isRoot {
|
||||||
|
@ -26,8 +27,19 @@ func readTree(tree zordTree.Tree, ts *Tree, isRoot bool) {
|
||||||
ts.Categories = make(map[string]int32)
|
ts.Categories = make(map[string]int32)
|
||||||
}
|
}
|
||||||
ts.Categories[category] = int32(len(subtree.Files))
|
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 {
|
for _, file := range tree.Files {
|
||||||
newFile := TreeFile{}
|
newFile := TreeFile{}
|
||||||
|
|
Loading…
Add table
Reference in a new issue