1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-20 13:49:42 +02:00

remove PR report, extend milestone use

This commit is contained in:
Elliott Stoneham 2016-08-19 12:42:01 +01:00
parent 20f77f359e
commit cc52106e20
5 changed files with 64 additions and 18 deletions

View file

@ -201,6 +201,7 @@ func (p *Provider) Render(ctx *provider.Context, config, data string) string {
payload.Config = c payload.Config = c
payload.Repo = c.RepoInfo payload.Repo = c.RepoInfo
payload.Limit = c.BranchLines payload.Limit = c.BranchLines
payload.List = c.Lists
ret := "" ret := ""
for _, repID := range c.ReportOrder { for _, repID := range c.ReportOrder {

View file

@ -33,6 +33,7 @@ type githubIssue struct {
LabelNames []string `json:"labelNames"` LabelNames []string `json:"labelNames"`
IsOpen bool `json:"isopen"` IsOpen bool `json:"isopen"`
Repo string `json:"repo"` Repo string `json:"repo"`
Milestone string `json:"milestone"`
} }
// sort issues in order that that should be presented - by date updated. // sort issues in order that that should be presented - by date updated.
@ -98,7 +99,7 @@ func init() {
{{end}} {{end}}
</div> </div>
<div class="github-commit-body"> <div class="github-commit-body">
<div class="github-commit-title"><span class="label-name">{{$data.Repo}} - {{$data.Message}}</span> {{$data.Labels}}</div> <div class="github-commit-title"><span class="label-name">{{$data.Repo}} - {{$data.Message}}</span> :{{$data.Milestone}}: {{$data.Labels}}</div>
<div class="github-commit-meta"> <div class="github-commit-meta">
#{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}}, last updated {{$data.Updated}} #{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}}, last updated {{$data.Updated}}
</div> </div>
@ -168,6 +169,12 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
n = *ptr.Login n = *ptr.Login
} }
} }
ms := noMilestone
if v.Milestone != nil {
if v.Milestone.Title != nil {
ms = *v.Milestone.Title
}
}
l, ln := wrapLabels(v.Labels) l, ln := wrapLabels(v.Labels)
ret = append(ret, githubIssue{ ret = append(ret, githubIssue{
Name: n, Name: n,
@ -180,6 +187,7 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
ID: *v.Number, ID: *v.Number,
IsOpen: *v.State == "open", IsOpen: *v.State == "open",
Repo: rName, Repo: rName,
Milestone: ms,
}) })
} }
} }

View file

@ -14,7 +14,6 @@ package github
import ( import (
"fmt" "fmt"
"sort" "sort"
"time"
"github.com/documize/community/core/log" "github.com/documize/community/core/log"
@ -34,31 +33,35 @@ type githubMilestone struct {
Progress uint `json:"progress"` 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 type milestonesToSort []githubMilestone
func (s milestonesToSort) Len() int { return len(s) } 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) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s milestonesToSort) Less(i, j int) bool { 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 { if !s[i].IsOpen && s[j].IsOpen {
return true return true
} }
if s[i].IsOpen && !s[j].IsOpen { if s[i].IsOpen && !s[j].IsOpen {
return false return false
} }
// TODO this seems a very slow approach if s[i].Progress == s[j].Progress { // order equal progress milestones
iDate, iErr := time.Parse(milestonesTimeFormat, s[i].UpdatedAt) return s[i].Name < s[j].Name
log.IfErr(iErr) }
jDate, jErr := time.Parse(milestonesTimeFormat, s[j].UpdatedAt) return s[i].Progress >= s[j].Progress // put more complete milestones first
log.IfErr(jErr)
return iDate.Before(jDate)
} }
const ( const (
tagMilestonesData = "milestonesData" tagMilestonesData = "milestonesData"
milestonesTimeFormat = "January 2 2006" milestonesTimeFormat = "January 2 2006"
noMilestone = "no milestone"
rawMSsvg = `<path d="M8 2H6V0h2v2zm4 5H2c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h10l2 2-2 2zM8 4H6v2h2V4zM6 16h2V8H6v8z"></path>` rawMSsvg = `<path d="M8 2H6V0h2v2zm4 5H2c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h10l2 2-2 2zM8 4H6v2h2V4zM6 16h2V8H6v8z"></path>`
openMSsvg = ` openMSsvg = `
@ -181,8 +184,6 @@ func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMiles
} }
sort.Stable(milestonesToSort(ret))
return ret, nil return ret, nil
} }
@ -208,5 +209,37 @@ func refreshMilestones(gr *githubRender, config *githubConfig, client *gogithub.
} }
func renderMilestones(payload *githubRender, c *githubConfig) error { 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 return nil
} }

View file

@ -37,10 +37,10 @@ type githubRender struct {
Milestones []githubMilestone `json:"milestones"` Milestones []githubMilestone `json:"milestones"`
OpenMS int `json:"openMS"` OpenMS int `json:"openMS"`
ClosedMS int `json:"closedMS"` ClosedMS int `json:"closedMS"`
PullRequests []githubPullRequest `json:"pullRequests"`
OpenPRs int `json:"openPRs"` OpenPRs int `json:"openPRs"`
ClosedPRs int `json:"closedPRs"` ClosedPRs int `json:"closedPRs"`
AuthorStats []githubAuthorStats `json:"authorStats"` AuthorStats []githubAuthorStats `json:"authorStats"`
//PullRequests []githubPullRequest `json:"pullRequests"`
} }
type report struct { type report struct {
@ -161,7 +161,7 @@ func (c *githubConfig) Clean() {
Color: "", 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 c.BranchLines = 100 // overide js default of 30 with maximum allowable in one call
} }

View file

@ -11,6 +11,8 @@
package github package github
/* Remove for now
import ( import (
"sort" "sort"
"time" "time"
@ -54,18 +56,18 @@ const (
tagPullRequestData = "pullRequestData" tagPullRequestData = "pullRequestData"
rawPRsvg = `<path d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path>` rawPRsvg = `<path d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path>`
openPRsvg = ` openPRsvg = `
<span title="Open Pull Request" > <span title="Open Pull Request" >
<svg height="16" width="12" version="1.1" viewBox="0 0 12 16"> <svg height="16" width="12" version="1.1" viewBox="0 0 12 16">
` + rawPRsvg + ` ` + rawPRsvg + `
</svg> </svg>
</span> </span>
` `
closedPRsvg = ` closedPRsvg = `
<span title="Closed Pull Request" > <span title="Closed Pull Request" >
<svg height="8" width="6" version="1.1" viewBox="0 0 12 16"> <svg height="8" width="6" version="1.1" viewBox="0 0 12 16">
` + rawPRsvg + ` ` + rawPRsvg + `
</svg> </svg>
</span> </span>
` `
) )
@ -190,3 +192,5 @@ func refreshPullReqs(gr *githubRender, config *githubConfig, client *gogithub.Cl
func renderPullReqs(payload *githubRender, c *githubConfig) error { func renderPullReqs(payload *githubRender, c *githubConfig) error {
return nil return nil
} }
*/