mirror of
https://github.com/documize/community.git
synced 2025-07-21 22:29:41 +02:00
add extra accumulations for proposed github sections
This commit is contained in:
parent
6f0d503cb5
commit
20f77f359e
7 changed files with 692 additions and 641 deletions
|
@ -45,7 +45,9 @@ type githubAuthorStats struct {
|
||||||
Author string `json:"author"`
|
Author string `json:"author"`
|
||||||
Avatar string `json:"avatar"`
|
Avatar string `json:"avatar"`
|
||||||
CommitCount int `json:"commitCount"`
|
CommitCount int `json:"commitCount"`
|
||||||
//TotalChanges int `json:"totalChanges"`
|
Repos []string `json:"repos"`
|
||||||
|
OpenIssues int `json:"openIssues"`
|
||||||
|
ClosedIssues int `json:"closedIssues"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort stats in order that that should be presented.
|
// sort stats in order that that should be presented.
|
||||||
|
@ -61,13 +63,16 @@ const tagCommitsData = "commitsData"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
reports[tagCommitsData] = report{refreshCommits, renderCommits, `
|
reports[tagCommitsData] = report{refreshCommits, renderCommits, `
|
||||||
<h3>Commits</h3>
|
<h3>Contributor activity since {{.Config.Since}}{{.Config.DateMessage}}</h3>
|
||||||
<div class="section-github-render">
|
<div class="section-github-render">
|
||||||
<table style="width:80%">
|
<table style="width:80%">
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{.CommitCount}} commits since {{.Config.Since}}{{.Config.DateMessage}}</th>
|
<th></th>
|
||||||
<th>Author</th>
|
<th>Author</th>
|
||||||
|
<th>Open Issues</th>
|
||||||
|
<th>Closed Issues</th>
|
||||||
<th>#commits</th>
|
<th>#commits</th>
|
||||||
|
<th>Branches</th>
|
||||||
</tr>
|
</tr>
|
||||||
{{range $stats := .AuthorStats}}
|
{{range $stats := .AuthorStats}}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -77,7 +82,14 @@ func init() {
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>{{$stats.Author}}</td>
|
<td>{{$stats.Author}}</td>
|
||||||
|
<td>{{$stats.OpenIssues}}</td>
|
||||||
|
<td>{{$stats.ClosedIssues}}</td>
|
||||||
<td>{{$stats.CommitCount}}</td>
|
<td>{{$stats.CommitCount}}</td>
|
||||||
|
<td>
|
||||||
|
{{range $repo := $stats.Repos}}
|
||||||
|
{{$repo}}
|
||||||
|
{{end}}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</table>
|
||||||
|
@ -117,6 +129,8 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubBranchCo
|
||||||
|
|
||||||
authorStats := make(map[string]githubAuthorStats)
|
authorStats := make(map[string]githubAuthorStats)
|
||||||
|
|
||||||
|
contribBranch := make(map[string]map[string]struct{})
|
||||||
|
|
||||||
overall := []githubBranchCommits{}
|
overall := []githubBranchCommits{}
|
||||||
|
|
||||||
for _, orb := range config.Lists {
|
for _, orb := range config.Lists {
|
||||||
|
@ -136,14 +150,12 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubBranchCo
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(guff) == 0 {
|
|
||||||
return []githubBranchCommits{}, []githubAuthorStats{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
day := ""
|
day := ""
|
||||||
newDay := ""
|
newDay := ""
|
||||||
ret := []githubDayCommits{}
|
ret := []githubDayCommits{}
|
||||||
|
|
||||||
|
thisBranch := fmt.Sprintf("%s/%s:%s", orb.Owner, orb.Repo, orb.Name)
|
||||||
|
|
||||||
for k, v := range guff {
|
for k, v := range guff {
|
||||||
|
|
||||||
if guff[k].Commit != nil {
|
if guff[k].Commit != nil {
|
||||||
|
@ -221,10 +233,15 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubBranchCo
|
||||||
Avatar: aa,
|
Avatar: aa,
|
||||||
URL: template.URL(u),
|
URL: template.URL(u),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if _, ok := contribBranch[al]; !ok {
|
||||||
|
contribBranch[al] = make(map[string]struct{})
|
||||||
|
}
|
||||||
|
contribBranch[al][thisBranch] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
overall = append(overall, githubBranchCommits{
|
overall = append(overall, githubBranchCommits{
|
||||||
Name: fmt.Sprintf("%s/%s:%s", orb.Owner, orb.Repo, orb.Name),
|
Name: thisBranch,
|
||||||
URL: fmt.Sprintf("https://github.com/%s/%s/tree/%s", orb.Owner, orb.Repo, orb.Name),
|
URL: fmt.Sprintf("https://github.com/%s/%s/tree/%s", orb.Owner, orb.Repo, orb.Name),
|
||||||
Days: ret,
|
Days: ret,
|
||||||
})
|
})
|
||||||
|
@ -233,6 +250,12 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubBranchCo
|
||||||
|
|
||||||
retStats := make([]githubAuthorStats, 0, len(authorStats))
|
retStats := make([]githubAuthorStats, 0, len(authorStats))
|
||||||
for _, v := range authorStats {
|
for _, v := range authorStats {
|
||||||
|
repos := contribBranch[v.Author]
|
||||||
|
v.Repos = make([]string, 0, len(repos))
|
||||||
|
for r := range repos {
|
||||||
|
v.Repos = append(v.Repos, r)
|
||||||
|
}
|
||||||
|
sort.Strings(v.Repos)
|
||||||
retStats = append(retStats, v)
|
retStats = append(retStats, v)
|
||||||
}
|
}
|
||||||
sort.Stable(asToSort(retStats))
|
sort.Stable(asToSort(retStats))
|
||||||
|
@ -260,5 +283,18 @@ func renderCommits(payload *githubRender, c *githubConfig) error {
|
||||||
payload.CommitCount += len(day.Commits)
|
payload.CommitCount += len(day.Commits)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for a := range payload.AuthorStats {
|
||||||
|
for i := range payload.Issues {
|
||||||
|
if payload.AuthorStats[a].Author == payload.Issues[i].Name {
|
||||||
|
if payload.Issues[i].IsOpen {
|
||||||
|
payload.AuthorStats[a].OpenIssues++
|
||||||
|
} else {
|
||||||
|
payload.AuthorStats[a].ClosedIssues++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ type githubIssue struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Avatar string `json:"avatar"`
|
Avatar string `json:"avatar"`
|
||||||
Labels template.HTML `json:"labels"`
|
Labels template.HTML `json:"labels"`
|
||||||
|
LabelNames []string `json:"labelNames"`
|
||||||
IsOpen bool `json:"isopen"`
|
IsOpen bool `json:"isopen"`
|
||||||
Repo string `json:"repo"`
|
Repo string `json:"repo"`
|
||||||
}
|
}
|
||||||
|
@ -73,7 +74,7 @@ const (
|
||||||
func init() {
|
func init() {
|
||||||
reports[tagIssuesData] = report{refreshIssues, renderIssues, `
|
reports[tagIssuesData] = report{refreshIssues, renderIssues, `
|
||||||
<div class="section-github-render">
|
<div class="section-github-render">
|
||||||
<h3>Issues</h3>
|
<h3>Issues: {{.ClosedIssues}} closed, {{.OpenIssues}} open</h3>
|
||||||
<p>
|
<p>
|
||||||
{{if .ShowList}}
|
{{if .ShowList}}
|
||||||
Including issues labelled
|
Including issues labelled
|
||||||
|
@ -97,9 +98,9 @@ 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.Message}}</span> {{$data.Labels}}</div>
|
<div class="github-commit-title"><span class="label-name">{{$data.Repo}} - {{$data.Message}}</span> {{$data.Labels}}</div>
|
||||||
<div class="github-commit-meta">
|
<div class="github-commit-meta">
|
||||||
#{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}} in {{$data.Repo}}, last updated {{$data.Updated}}
|
#{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}}, last updated {{$data.Updated}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -112,12 +113,13 @@ func init() {
|
||||||
`}
|
`}
|
||||||
}
|
}
|
||||||
|
|
||||||
func wrapLabels(labels []gogithub.Label) string {
|
func wrapLabels(labels []gogithub.Label) (l string, labelNames []string) {
|
||||||
l := ""
|
labelNames = make([]string, 0, len(labels))
|
||||||
for _, ll := range labels {
|
for _, ll := range labels {
|
||||||
|
labelNames = append(labelNames, *ll.Name)
|
||||||
l += `<span class="github-issue-label" style="background-color:#` + *ll.Color + `">` + *ll.Name + `</span> `
|
l += `<span class="github-issue-label" style="background-color:#` + *ll.Color + `">` + *ll.Name + `</span> `
|
||||||
}
|
}
|
||||||
return l
|
return l, labelNames
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, error) {
|
func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, error) {
|
||||||
|
@ -166,7 +168,7 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
|
||||||
n = *ptr.Login
|
n = *ptr.Login
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
l := wrapLabels(v.Labels)
|
l, ln := wrapLabels(v.Labels)
|
||||||
ret = append(ret, githubIssue{
|
ret = append(ret, githubIssue{
|
||||||
Name: n,
|
Name: n,
|
||||||
Message: *v.Title,
|
Message: *v.Title,
|
||||||
|
@ -174,6 +176,7 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
|
||||||
Updated: v.UpdatedAt.Format(issuesTimeFormat),
|
Updated: v.UpdatedAt.Format(issuesTimeFormat),
|
||||||
URL: template.URL(*v.HTMLURL),
|
URL: template.URL(*v.HTMLURL),
|
||||||
Labels: template.HTML(l),
|
Labels: template.HTML(l),
|
||||||
|
LabelNames: ln,
|
||||||
ID: *v.Number,
|
ID: *v.Number,
|
||||||
IsOpen: *v.State == "open",
|
IsOpen: *v.State == "open",
|
||||||
Repo: rName,
|
Repo: rName,
|
||||||
|
@ -201,12 +204,32 @@ func refreshIssues(gr *githubRender, config *githubConfig, client *gogithub.Clie
|
||||||
|
|
||||||
gr.OpenIssues = 0
|
gr.OpenIssues = 0
|
||||||
gr.ClosedIssues = 0
|
gr.ClosedIssues = 0
|
||||||
|
sharedLabels := make(map[string][]string)
|
||||||
for _, v := range gr.Issues {
|
for _, v := range gr.Issues {
|
||||||
if v.IsOpen {
|
if v.IsOpen {
|
||||||
gr.OpenIssues++
|
gr.OpenIssues++
|
||||||
} else {
|
} else {
|
||||||
gr.ClosedIssues++
|
gr.ClosedIssues++
|
||||||
}
|
}
|
||||||
|
for _, lab := range v.LabelNames {
|
||||||
|
sharedLabels[lab] = append(sharedLabels[lab], v.Repo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gr.SharedLabels = make([]template.HTML, 0, len(sharedLabels)) // will usually be too big
|
||||||
|
for name, repos := range sharedLabels {
|
||||||
|
if len(repos) > 1 {
|
||||||
|
lab := name + ":["
|
||||||
|
for i, r := range repos {
|
||||||
|
if i > 0 {
|
||||||
|
lab += " "
|
||||||
|
}
|
||||||
|
lab += "<a href='https://github.com/" + r +
|
||||||
|
"/issues?q=is%3Aissue+label%3A" + name + "'>" + r + "</a>"
|
||||||
|
}
|
||||||
|
lab += "] "
|
||||||
|
gr.SharedLabels = append(gr.SharedLabels, template.HTML(lab))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -31,6 +31,7 @@ type githubMilestone struct {
|
||||||
CompleteMsg string `json:"completeMsg"`
|
CompleteMsg string `json:"completeMsg"`
|
||||||
DueDate string `json:"dueDate"`
|
DueDate string `json:"dueDate"`
|
||||||
UpdatedAt string `json:"updatedAt"`
|
UpdatedAt string `json:"updatedAt"`
|
||||||
|
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 - by date updated.
|
||||||
|
@ -79,7 +80,7 @@ const (
|
||||||
func init() {
|
func init() {
|
||||||
reports[tagMilestonesData] = report{refreshMilestones, renderMilestones, `
|
reports[tagMilestonesData] = report{refreshMilestones, renderMilestones, `
|
||||||
<div class="section-github-render">
|
<div class="section-github-render">
|
||||||
<h3>Milestones</h3>
|
<h3>Milestones: {{.ClosedMS}} closed, {{.OpenMS}} open</h3>
|
||||||
<div class="github-board">
|
<div class="github-board">
|
||||||
<ul class="github-list">
|
<ul class="github-list">
|
||||||
{{range $data := .Milestones}}
|
{{range $data := .Milestones}}
|
||||||
|
@ -93,7 +94,9 @@ 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.Name}}</span> </div>
|
<div class="github-commit-title"><span class="label-name">{{$data.Repo}} - {{$data.Name}}</span>
|
||||||
|
<progress value="{{$data.Progress}}" max="100">
|
||||||
|
</div>
|
||||||
<div class="github-commit-meta">
|
<div class="github-commit-meta">
|
||||||
{{$data.DueDate}} Last updated {{$data.UpdatedAt}}.
|
{{$data.DueDate}} Last updated {{$data.UpdatedAt}}.
|
||||||
{{$data.CompleteMsg}} complete {{$data.OpenIssues}} open {{$data.ClosedIssues}} closed
|
{{$data.CompleteMsg}} complete {{$data.OpenIssues}} open {{$data.ClosedIssues}} closed
|
||||||
|
@ -154,6 +157,8 @@ func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMiles
|
||||||
up = (*v.UpdatedAt).Format(milestonesTimeFormat)
|
up = (*v.UpdatedAt).Format(milestonesTimeFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progress := float64(*v.ClosedIssues*100) / float64(*v.OpenIssues+*v.ClosedIssues)
|
||||||
|
|
||||||
ret = append(ret, githubMilestone{
|
ret = append(ret, githubMilestone{
|
||||||
Repo: rName,
|
Repo: rName,
|
||||||
Name: *v.Title,
|
Name: *v.Title,
|
||||||
|
@ -161,9 +166,10 @@ func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMiles
|
||||||
IsOpen: *v.State == "open",
|
IsOpen: *v.State == "open",
|
||||||
OpenIssues: *v.OpenIssues,
|
OpenIssues: *v.OpenIssues,
|
||||||
ClosedIssues: *v.ClosedIssues,
|
ClosedIssues: *v.ClosedIssues,
|
||||||
CompleteMsg: fmt.Sprintf("%2.0f%%", float64(*v.ClosedIssues*100)/float64(*v.OpenIssues+*v.ClosedIssues)),
|
CompleteMsg: fmt.Sprintf("%2.0f%%", progress),
|
||||||
DueDate: dd,
|
DueDate: dd,
|
||||||
UpdatedAt: up,
|
UpdatedAt: up,
|
||||||
|
Progress: uint(progress),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package github
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/documize/community/core/log"
|
"github.com/documize/community/core/log"
|
||||||
|
@ -29,6 +30,7 @@ type githubRender struct {
|
||||||
BranchCommits []githubBranchCommits `json:"branchCommits"`
|
BranchCommits []githubBranchCommits `json:"branchCommits"`
|
||||||
CommitCount int `json:"commitCount"`
|
CommitCount int `json:"commitCount"`
|
||||||
Issues []githubIssue `json:"issues"`
|
Issues []githubIssue `json:"issues"`
|
||||||
|
SharedLabels []template.HTML `json:"sharedLabels"`
|
||||||
OpenIssues int `json:"openIssues"`
|
OpenIssues int `json:"openIssues"`
|
||||||
ClosedIssues int `json:"closedIssues"`
|
ClosedIssues int `json:"closedIssues"`
|
||||||
Limit int `json:"limit"`
|
Limit int `json:"limit"`
|
||||||
|
@ -79,6 +81,16 @@ type githubBranch struct {
|
||||||
Color string `json:"color,omitempty"`
|
Color string `json:"color,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type githubLabel struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Owner string `json:"owner"`
|
||||||
|
Repo string `json:"repo"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Included bool `json:"included"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Color string `json:"color,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type githubConfig struct {
|
type githubConfig struct {
|
||||||
Token string `json:"-"` // NOTE very important that the secret Token is not leaked to the client side, so "-"
|
Token string `json:"-"` // NOTE very important that the secret Token is not leaked to the client side, so "-"
|
||||||
UserID string `json:"userId"`
|
UserID string `json:"userId"`
|
||||||
|
|
|
@ -73,7 +73,7 @@ const (
|
||||||
func init() {
|
func init() {
|
||||||
reports[tagPullRequestData] = report{refreshPullReqs, renderPullReqs, `
|
reports[tagPullRequestData] = report{refreshPullReqs, renderPullReqs, `
|
||||||
<div class="section-github-render">
|
<div class="section-github-render">
|
||||||
<h3>Pull Requests</h3>
|
<h3>Pull Requests: {{.ClosedPRs}} closed, {{.OpenPRs}} open</h3>
|
||||||
<div class="github-board">
|
<div class="github-board">
|
||||||
<ul class="github-list">
|
<ul class="github-list">
|
||||||
{{range $data := .PullRequests}}
|
{{range $data := .PullRequests}}
|
||||||
|
|
|
@ -34,49 +34,23 @@ func (s branchesToSort) Less(i, j int) bool {
|
||||||
func init() {
|
func init() {
|
||||||
reports[tagSummaryData] = report{refreshSummary, renderSummary, `
|
reports[tagSummaryData] = report{refreshSummary, renderSummary, `
|
||||||
<div class="section-github-render">
|
<div class="section-github-render">
|
||||||
<h3>Summary</h3>
|
<h3>
|
||||||
<div class="github-board">
|
Activity since {{.Config.Since}}{{.Config.DateMessage}} for repository branches [
|
||||||
For repository branches:
|
|
||||||
<ul>
|
|
||||||
{{range $data := .Config.Lists}}
|
{{range $data := .Config.Lists}}
|
||||||
{{if $data.Included}}
|
{{if $data.Included}}
|
||||||
<li>
|
|
||||||
<a class="link" href="{{$data.URL}}">
|
<a class="link" href="{{$data.URL}}">
|
||||||
{{$data.Owner}}/{{$data.Repo}}:{{$data.Name}}
|
{{$data.Owner}}/{{$data.Repo}}:{{$data.Name}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
]
|
||||||
<table style="width:80%">
|
</h3>
|
||||||
<tr>
|
<h3>
|
||||||
<th></th>
|
Shared Tags:
|
||||||
<th colspan=2>Closed since {{.Config.Since}}{{.Config.DateMessage}}</th>
|
{{range $slabel := .SharedLabels}}
|
||||||
<th colspan=2>Still Open</th>
|
{{$slabel}}
|
||||||
</tr>
|
{{end}}
|
||||||
<tr>
|
</h3>
|
||||||
<td>Milestones</td>
|
|
||||||
<th width=20>` + closedMSsvg + `</td>
|
|
||||||
<td>{{.ClosedMS}}</td>
|
|
||||||
<td width=20>` + openMSsvg + `</td>
|
|
||||||
<td>{{.OpenMS}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Issues</td>
|
|
||||||
<td>` + closedIsvg + `</td>
|
|
||||||
<td>{{.ClosedIssues}}</td>
|
|
||||||
<td>` + openIsvg + `</td>
|
|
||||||
<td>{{.OpenIssues}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Pull requests</td>
|
|
||||||
<td>` + closedPRsvg + `</td>
|
|
||||||
<td>{{.ClosedPRs}}</td>
|
|
||||||
<td>` + openPRsvg + `</td>
|
|
||||||
<td>{{.OpenPRs}}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
`}
|
`}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue