diff --git a/core/section/trello/boards_template.go b/core/section/trello/boards_template.go index 1f2a758b..3309b173 100644 --- a/core/section/trello/boards_template.go +++ b/core/section/trello/boards_template.go @@ -34,13 +34,13 @@ const boardsTemplate = ` - {{range $act, $tot := $b.ActionSummary}} - {{$tot}} {{$act}}{{if ne 1 $tot}}s{{end}}, - {{end}} + {{range $idx, $act := $b.ActionSummary}}{{if ne $idx 0}}{{- ","}} {{end}}{{$act.Count}} {{$act.Name -}}{{if ne 1 $act.Count}}{{"s" -}}{{end}}{{end}}{{if gt (len $b.Archived) 0}}, {{end}} {{if gt (len $b.Archived) 0}} - {{len $b.Archived}} {{if eq 1 (len $b.Archived)}}card {{else}} cards {{end}}archived + {{len $b.Archived}} {{if eq 1 (len $b.Archived)}}card {{else}} cards {{end}}archived {{else}} - no cards archived + {{if eq (len $b.ActionSummary) 0}} + no activity + {{end}} {{end}}
diff --git a/core/section/trello/model.go b/core/section/trello/model.go index 5d4da504..a136b58f 100644 --- a/core/section/trello/model.go +++ b/core/section/trello/model.go @@ -183,7 +183,7 @@ type trelloBoard struct { Blue string `json:"blue"` Purple string `json:"purple"` } `json:"labelNames"` - Included bool `json:"included"` // indicates whether we display this board + Included bool `json:"included"` // indicates whether we display this board NamePath string `json:"namePath"` // the "team / board" form } @@ -253,13 +253,18 @@ type trelloListCards struct { Cards []trelloCard } +type trelloActionSummaryEntry struct { + Name string + Count int +} + type trelloRenderBoard struct { Board trelloBoard Data []trelloListCards CardCount int ListCount int Actions []trelloAction - ActionSummary map[string]int + ActionSummary []trelloActionSummaryEntry Archived []trelloCard } diff --git a/core/section/trello/trello.go b/core/section/trello/trello.go index 23ed12b3..4fa3e36f 100644 --- a/core/section/trello/trello.go +++ b/core/section/trello/trello.go @@ -601,9 +601,8 @@ func buildPayloadAnalysis(config *trelloConfig, render *trelloRender) { } // ActionSummary - if render.Boards[brdIdx].ActionSummary == nil { - render.Boards[brdIdx].ActionSummary = make(map[string]int) - } + actionSummaryMap := make(map[string]int) + for _, act := range brd.Actions { englishType := "" for _, c := range act.Type { @@ -619,9 +618,20 @@ func buildPayloadAnalysis(config *trelloConfig, render *trelloRender) { englishType = newTxt } if len(englishType) > 0 { - render.Boards[brdIdx].ActionSummary[englishType]++ + actionSummaryMap[englishType]++ } } + acts := make([]string, 0, len(actionSummaryMap)) + for a := range actionSummaryMap { + acts = append(acts, a) + } + sort.Strings(acts) + render.Boards[brdIdx].ActionSummary = make([]trelloActionSummaryEntry, len(acts)) + for k, v := range acts { + render.Boards[brdIdx].ActionSummary[k] = trelloActionSummaryEntry{Name: v, Count: actionSummaryMap[v]} + + } + } //post-process labels