1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-25 08:09:43 +02:00

change Trello activity reporting to be more concise

This commit is contained in:
Elliott Stoneham 2016-09-15 17:08:51 +01:00
parent cf01d9365a
commit 44716e8b9e
3 changed files with 26 additions and 11 deletions

View file

@ -34,13 +34,13 @@ const boardsTemplate = `
<!-- {{ len $b.Actions }}{{if eq 1 (len $b.Actions)}} action {{else}} actions {{end}} -->
</div>
<span class="board-meta">
{{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}}
<br>
</span>

View file

@ -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
}

View file

@ -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