Skip to content

Commit

Permalink
fix: make ranking by keys && fixed #14
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 17, 2020
1 parent f385398 commit 644538f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/cloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"github.com/boyter/scc/processor"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/spf13/cobra"
"io/ioutil"
Expand Down Expand Up @@ -138,7 +139,9 @@ func convertToCsv(outputFiles []string, keys []string) {
for _, langSummary := range dirLangSummary {
if key == langSummary.Name {
hasSet = true
langSummary.Name = key
languageMap[dirName][key] = langSummary
break
}
}
if !hasSet {
Expand All @@ -151,17 +154,23 @@ func convertToCsv(outputFiles []string, keys []string) {
baseKey := []string{"package", "summary"}
data = append(data, append(baseKey, keys...))

deb, _ := json.Marshal(languageMap)
cmd_util.WriteToCocaFile("debug_cloc.json", string(deb))

for dirName, dirSummary := range languageMap {
var column []string
column = append(column, dirName)

var codes []string
var summary int64
for _, lang := range dirSummary {

for _, key := range keys {
lang := dirSummary[key]
summary = summary + lang.Code
codes = append(codes, strconv.Itoa(int(lang.Code)))
}

fmt.Println(codes)
column = append(column, strconv.Itoa(int(summary)));
column = append(column, codes...)
data = append(data, column);
Expand Down

0 comments on commit 644538f

Please sign in to comment.