diff --git a/core/section/trello/graphs_template.go b/core/section/trello/graphs_template.go
index 770e9b98..3bb41687 100644
--- a/core/section/trello/graphs_template.go
+++ b/core/section/trello/graphs_template.go
@@ -12,17 +12,21 @@
package trello
const graphsTemplate = `
-
Single Boards (graphs)
-{{range $b := .Boards}}
-
-
There are {{ $b.CardCount }} cards across {{ $b.ListCount }} lists for board {{$b.Board.Name}}.
+{{if false}}
+
+
Single Boards (graphs)
+ {{range $b := .Boards}}
- {{range $data := $b.Data}}
-
-
{{ $data.List.Name }}
-
- {{end}}
+
There are {{ $b.CardCount }} cards across {{ $b.ListCount }} lists for board {{$b.Board.Name}}.
+
+ {{range $data := $b.Data}}
+
+
{{ $data.List.Name }}
+
+ {{end}}
+
-
+ {{end}}
+
{{end}}
`
diff --git a/core/section/trello/master_template.go b/core/section/trello/master_template.go
index dbd39848..0faa6b70 100644
--- a/core/section/trello/master_template.go
+++ b/core/section/trello/master_template.go
@@ -15,7 +15,7 @@ const renderTemplate = `
Header for Trello Multi-Board Test (in master_template.go)
` + labelsTemplate +
boardsTemplate +
- // graphsTemplate +
+ graphsTemplate +
membersTemplate +
archiveTemplate +
tradTemplate +
diff --git a/core/section/trello/model.go b/core/section/trello/model.go
index 117e7154..6af968f6 100644
--- a/core/section/trello/model.go
+++ b/core/section/trello/model.go
@@ -11,18 +11,23 @@
package trello
-import "strings"
+import (
+ "strings"
+ "time"
+)
type secrets struct {
Token string `json:"token"`
}
type trelloConfig struct {
- AppKey string `json:"appKey"`
- Token string `json:"token"`
- Board trelloBoard `json:"board"` // TODO review
- Lists []trelloList `json:"lists"` // TODO review
- Boards []trelloBoard `json:"boards"`
+ AppKey string `json:"appKey"`
+ Token string `json:"token"`
+ Board trelloBoard `json:"board"`
+ Lists []trelloList `json:"lists"`
+ Boards []trelloBoard `json:"boards"`
+ Since string `json:"since,omitempty"`
+ SincePtr *time.Time `json:"-"`
}
func (c *trelloConfig) Clean() {
@@ -162,6 +167,7 @@ type trelloBoard struct {
Blue string `json:"blue"`
Purple string `json:"purple"`
} `json:"labelNames"`
+ Included bool `json:"included"` // indicates whether we display this board
}
type trelloBoardBackground struct {
@@ -258,6 +264,8 @@ type trelloBoardAssign struct {
}
type trelloRender struct {
+ Config trelloConfig
+
Boards []trelloRenderBoard
Since string
diff --git a/core/section/trello/trad_template.go b/core/section/trello/trad_template.go
index 59fcc6d1..eafdf68b 100644
--- a/core/section/trello/trad_template.go
+++ b/core/section/trello/trad_template.go
@@ -12,8 +12,7 @@
package trello
const tradTemplate = `
-{{if eq 1 (len .Boards)}}
-
#Board Name
+{{if false}}
{{range $b := .Boards}}
Non-printable
diff --git a/core/section/trello/trello.go b/core/section/trello/trello.go
index 22d3ba3d..36b6a142 100644
--- a/core/section/trello/trello.go
+++ b/core/section/trello/trello.go
@@ -183,45 +183,67 @@ func (*Provider) Render(ctx *provider.Context, config, data string) string {
// Refresh just sends back data as-is.
func (*Provider) Refresh(ctx *provider.Context, config, data string) string {
var c = trelloConfig{}
- json.Unmarshal([]byte(config), &c)
+ log.IfErr(json.Unmarshal([]byte(config), &c))
save := trelloRender{}
+ save.Config = c
save.Boards = make([]trelloRenderBoard, 0, len(c.Boards))
- for _, board := range c.Boards {
-
- var payload = trelloRenderBoard{}
-
- c.Board = board
- c.AppKey = request.ConfigString(meta.ConfigHandle(), "appKey")
-
- lsts, err := getLists(c)
- log.IfErr(err)
- if err == nil {
- c.Lists = lsts
+ if len(c.Since) >= len("yyyy/mm/dd hh:ss") {
+ var since time.Time
+ tt := []byte("yyyy-mm-ddThh:mm:00Z")
+ for _, i := range []int{0, 1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15} {
+ tt[i] = c.Since[i]
}
-
- for l := range c.Lists {
- c.Lists[l].Included = true
+ err := since.UnmarshalText(tt)
+ if err != nil {
+ log.ErrorString("Date unmarshall '" + c.Since + "'->'" + string(tt) + "' error: " + err.Error())
+ } else {
+ c.SincePtr = &since
}
-
- refreshed, err := getCards(c)
- log.IfErr(err)
-
- payload.Board = c.Board
- payload.Data = refreshed
- payload.ListCount = len(refreshed)
-
- for _, list := range refreshed {
- payload.CardCount += len(list.Cards)
- }
-
- payload.Actions, payload.Archived = fetchBoardActions(&c, &save, board.ID, nil) // TODO pass in date
-
- save.Boards = append(save.Boards, payload)
}
+ dateMessage := ""
+ if c.SincePtr == nil {
+ dateMessage = " (the last 7 days)"
+ since := time.Now().AddDate(0, 0, -7)
+ c.SincePtr = &since
+ c.Since = (*c.SincePtr).Format("2006/01/02 ")
+ }
+ save.Since = (*c.SincePtr).Format("January 2, 2006") + dateMessage
- save.Since = "# 1 Aug 2016 #"
+ for _, board := range c.Boards {
+ if board.Included {
+ var payload = trelloRenderBoard{}
+
+ c.Board = board
+ c.AppKey = request.ConfigString(meta.ConfigHandle(), "appKey")
+
+ lsts, err := getLists(c)
+ log.IfErr(err)
+ if err == nil {
+ c.Lists = lsts
+ }
+
+ for l := range c.Lists {
+ c.Lists[l].Included = true
+ }
+
+ refreshed, err := getCards(c)
+ log.IfErr(err)
+
+ payload.Board = c.Board
+ payload.Data = refreshed
+ payload.ListCount = len(refreshed)
+
+ for _, list := range refreshed {
+ payload.CardCount += len(list.Cards)
+ }
+
+ payload.Actions, payload.Archived = fetchBoardActions(&c, &save, board.ID, c.Since)
+
+ save.Boards = append(save.Boards, payload)
+ }
+ }
j, err := json.Marshal(save)
@@ -268,6 +290,10 @@ func getBoards(config trelloConfig) (boards []trelloBoard, err error) {
return nil, err
}
+ for bx := range boards {
+ boards[bx].Included = true // include boards by default
+ }
+
return boards, nil
}
@@ -387,9 +413,9 @@ func fetchMember(config *trelloConfig, render *trelloRender, memberID string) (m
return
}
-func fetchBoardActions(config *trelloConfig, render *trelloRender, boardID string, since *time.Time) (actions []trelloAction, archived []trelloCard) {
+func fetchBoardActions(config *trelloConfig, render *trelloRender, boardID string, since string) (actions []trelloAction, archived []trelloCard) {
- sinceString := "2016-08-01" // TODO
+ sinceString := since[:10]
if len(config.AppKey) == 0 {
config.AppKey = request.ConfigString(meta.ConfigHandle(), "appKey")