diff --git a/core/section/github/github.go b/core/section/github/github.go
index 00d3f3cd..a394cf34 100644
--- a/core/section/github/github.go
+++ b/core/section/github/github.go
@@ -201,6 +201,7 @@ func (p *Provider) Render(ctx *provider.Context, config, data string) string {
payload.Config = c
payload.Repo = c.RepoInfo
payload.Limit = c.BranchLines
+ payload.List = c.Lists
ret := ""
for _, repID := range c.ReportOrder {
diff --git a/core/section/github/issues.go b/core/section/github/issues.go
index dd5488d1..489d9768 100644
--- a/core/section/github/issues.go
+++ b/core/section/github/issues.go
@@ -33,6 +33,7 @@ type githubIssue struct {
LabelNames []string `json:"labelNames"`
IsOpen bool `json:"isopen"`
Repo string `json:"repo"`
+ Milestone string `json:"milestone"`
}
// sort issues in order that that should be presented - by date updated.
@@ -98,7 +99,7 @@ func init() {
{{end}}
-
{{$data.Repo}} - {{$data.Message}} {{$data.Labels}}
+
{{$data.Repo}} - {{$data.Message}} :{{$data.Milestone}}: {{$data.Labels}}
#{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}}, last updated {{$data.Updated}}
@@ -168,6 +169,12 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
n = *ptr.Login
}
}
+ ms := noMilestone
+ if v.Milestone != nil {
+ if v.Milestone.Title != nil {
+ ms = *v.Milestone.Title
+ }
+ }
l, ln := wrapLabels(v.Labels)
ret = append(ret, githubIssue{
Name: n,
@@ -180,6 +187,7 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
ID: *v.Number,
IsOpen: *v.State == "open",
Repo: rName,
+ Milestone: ms,
})
}
}
diff --git a/core/section/github/milestones.go b/core/section/github/milestones.go
index 7cc57d0d..32b2279e 100644
--- a/core/section/github/milestones.go
+++ b/core/section/github/milestones.go
@@ -14,7 +14,6 @@ package github
import (
"fmt"
"sort"
- "time"
"github.com/documize/community/core/log"
@@ -34,31 +33,35 @@ type githubMilestone struct {
Progress uint `json:"progress"`
}
-// sort milestones in order that that should be presented - by date updated.
+// sort milestones in order that that should be presented.
type milestonesToSort []githubMilestone
func (s milestonesToSort) Len() int { return len(s) }
func (s milestonesToSort) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s milestonesToSort) Less(i, j int) bool {
+ if s[i].Repo < s[j].Repo {
+ return true
+ }
+ if s[i].Repo > s[j].Repo {
+ return false
+ }
if !s[i].IsOpen && s[j].IsOpen {
return true
}
if s[i].IsOpen && !s[j].IsOpen {
return false
}
- // TODO this seems a very slow approach
- iDate, iErr := time.Parse(milestonesTimeFormat, s[i].UpdatedAt)
- log.IfErr(iErr)
- jDate, jErr := time.Parse(milestonesTimeFormat, s[j].UpdatedAt)
- log.IfErr(jErr)
- return iDate.Before(jDate)
-
+ if s[i].Progress == s[j].Progress { // order equal progress milestones
+ return s[i].Name < s[j].Name
+ }
+ return s[i].Progress >= s[j].Progress // put more complete milestones first
}
const (
tagMilestonesData = "milestonesData"
milestonesTimeFormat = "January 2 2006"
+ noMilestone = "no milestone"
rawMSsvg = `
`
openMSsvg = `
@@ -181,8 +184,6 @@ func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMiles
}
- sort.Stable(milestonesToSort(ret))
-
return ret, nil
}
@@ -208,5 +209,37 @@ func refreshMilestones(gr *githubRender, config *githubConfig, client *gogithub.
}
func renderMilestones(payload *githubRender, c *githubConfig) error {
+ fmt.Println("DEBUG renderMilestones list", payload.List)
+ hadRepo := make(map[string]bool)
+ for _, orb := range payload.List {
+ fmt.Println("DEBUG branch", orb)
+ rName := orb.Owner + "/" + orb.Repo
+ if !hadRepo[rName] {
+
+ fmt.Println("DEBUG found repo", rName)
+ issuesOpen, issuesClosed := 0, 0
+ for _, iss := range payload.Issues {
+ fmt.Println("DEBUG issue", iss)
+ if iss.Repo == rName {
+ fmt.Println("DEBUG Found issue", iss)
+ if iss.Milestone == noMilestone {
+ if iss.IsOpen {
+ issuesOpen++
+ } else {
+ issuesClosed++
+ }
+ }
+ }
+ }
+ payload.Milestones = append(payload.Milestones, githubMilestone{
+ Repo: rName, Name: noMilestone, OpenIssues: issuesOpen, ClosedIssues: issuesClosed,
+ })
+
+ hadRepo[rName] = true
+ }
+ }
+
+ sort.Stable(milestonesToSort(payload.Milestones))
+
return nil
}
diff --git a/core/section/github/model.go b/core/section/github/model.go
index 279ef022..0764756b 100644
--- a/core/section/github/model.go
+++ b/core/section/github/model.go
@@ -37,10 +37,10 @@ type githubRender struct {
Milestones []githubMilestone `json:"milestones"`
OpenMS int `json:"openMS"`
ClosedMS int `json:"closedMS"`
- PullRequests []githubPullRequest `json:"pullRequests"`
OpenPRs int `json:"openPRs"`
ClosedPRs int `json:"closedPRs"`
AuthorStats []githubAuthorStats `json:"authorStats"`
+ //PullRequests []githubPullRequest `json:"pullRequests"`
}
type report struct {
@@ -161,7 +161,7 @@ func (c *githubConfig) Clean() {
Color: "",
})
}
- c.ReportOrder = []string{tagSummaryData, tagMilestonesData, tagIssuesData, tagPullRequestData, tagCommitsData}
+ c.ReportOrder = []string{tagSummaryData, tagMilestonesData, tagIssuesData /*, tagPullRequestData*/, tagCommitsData}
c.BranchLines = 100 // overide js default of 30 with maximum allowable in one call
}
diff --git a/core/section/github/pullrequests.go b/core/section/github/pullrequests.go
index 6fb9be52..fece4bae 100644
--- a/core/section/github/pullrequests.go
+++ b/core/section/github/pullrequests.go
@@ -11,6 +11,8 @@
package github
+/* Remove for now
+
import (
"sort"
"time"
@@ -54,18 +56,18 @@ const (
tagPullRequestData = "pullRequestData"
rawPRsvg = `
`
- openPRsvg = `
+ openPRsvg = `
+
`
- closedPRsvg = `
+ closedPRsvg = `
+
`
)
@@ -190,3 +192,5 @@ func refreshPullReqs(gr *githubRender, config *githubConfig, client *gogithub.Cl
func renderPullReqs(payload *githubRender, c *githubConfig) error {
return nil
}
+
+*/