1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-28 01:29: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}} --> <!-- {{ len $b.Actions }}{{if eq 1 (len $b.Actions)}} action {{else}} actions {{end}} -->
</div> </div>
<span class="board-meta"> <span class="board-meta">
{{range $act, $tot := $b.ActionSummary}} {{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}}
{{$tot}} {{$act}}{{if ne 1 $tot}}s{{end}},
{{end}}
{{if gt (len $b.Archived) 0}} {{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}} {{else}}
no cards archived {{if eq (len $b.ActionSummary) 0}}
no activity
{{end}}
{{end}} {{end}}
<br> <br>
</span> </span>

View file

@ -183,7 +183,7 @@ type trelloBoard struct {
Blue string `json:"blue"` Blue string `json:"blue"`
Purple string `json:"purple"` Purple string `json:"purple"`
} `json:"labelNames"` } `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 NamePath string `json:"namePath"` // the "team / board" form
} }
@ -253,13 +253,18 @@ type trelloListCards struct {
Cards []trelloCard Cards []trelloCard
} }
type trelloActionSummaryEntry struct {
Name string
Count int
}
type trelloRenderBoard struct { type trelloRenderBoard struct {
Board trelloBoard Board trelloBoard
Data []trelloListCards Data []trelloListCards
CardCount int CardCount int
ListCount int ListCount int
Actions []trelloAction Actions []trelloAction
ActionSummary map[string]int ActionSummary []trelloActionSummaryEntry
Archived []trelloCard Archived []trelloCard
} }

View file

@ -601,9 +601,8 @@ func buildPayloadAnalysis(config *trelloConfig, render *trelloRender) {
} }
// ActionSummary // ActionSummary
if render.Boards[brdIdx].ActionSummary == nil { actionSummaryMap := make(map[string]int)
render.Boards[brdIdx].ActionSummary = make(map[string]int)
}
for _, act := range brd.Actions { for _, act := range brd.Actions {
englishType := "" englishType := ""
for _, c := range act.Type { for _, c := range act.Type {
@ -619,9 +618,20 @@ func buildPayloadAnalysis(config *trelloConfig, render *trelloRender) {
englishType = newTxt englishType = newTxt
} }
if len(englishType) > 0 { 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 //post-process labels