mirror of
https://github.com/documize/community.git
synced 2025-07-21 14:19:43 +02:00
add user stats where no commits, add HasX flags for template
This commit is contained in:
parent
ba1512c7cd
commit
603db6fc15
4 changed files with 34 additions and 10 deletions
|
@ -31,7 +31,7 @@ type githubCommit struct {
|
|||
Branch string `json:"branch"`
|
||||
ShowBranch bool `json:"ShowBranch"`
|
||||
Date string `json:"date"`
|
||||
BinDate time.Time `json:"-"`
|
||||
BinDate time.Time `json:"-"` // only used for sorting
|
||||
ShowDate bool `json:"ShowDate"`
|
||||
Name string `json:"name"`
|
||||
Avatar string `json:"avatar"`
|
||||
|
@ -279,18 +279,31 @@ func renderCommits(payload *githubRender, c *githubConfig) error {
|
|||
for range payload.BranchCommits {
|
||||
payload.CommitCount++
|
||||
}
|
||||
payload.HasCommits = payload.CommitCount > 0
|
||||
|
||||
for a := range payload.AuthorStats {
|
||||
for i := range payload.Issues {
|
||||
for i := range payload.Issues {
|
||||
var author int
|
||||
for a := range payload.AuthorStats {
|
||||
if payload.AuthorStats[a].Author == payload.Issues[i].Name {
|
||||
if payload.Issues[i].IsOpen {
|
||||
payload.AuthorStats[a].OpenIssues++
|
||||
} else {
|
||||
payload.AuthorStats[a].ClosedIssues++
|
||||
}
|
||||
author = a
|
||||
goto found
|
||||
}
|
||||
}
|
||||
// no Author found for issue, so create one
|
||||
payload.AuthorStats = append(payload.AuthorStats, githubAuthorStats{
|
||||
Author: payload.Issues[i].Name,
|
||||
Avatar: payload.Issues[i].Avatar,
|
||||
})
|
||||
author = len(payload.AuthorStats) - 1
|
||||
found:
|
||||
if payload.Issues[i].IsOpen {
|
||||
payload.AuthorStats[author].OpenIssues++
|
||||
} else {
|
||||
payload.AuthorStats[author].ClosedIssues++
|
||||
}
|
||||
}
|
||||
payload.HasAuthorStats = len(payload.AuthorStats) > 0
|
||||
sort.Stable(asToSort(payload.AuthorStats))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -136,11 +136,13 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
|
|||
}
|
||||
|
||||
for _, v := range guff {
|
||||
n := ""
|
||||
ptr := v.User
|
||||
n := "(unassigned)"
|
||||
av := githubGravatar
|
||||
ptr := v.Assignee
|
||||
if ptr != nil {
|
||||
if ptr.Login != nil {
|
||||
n = *ptr.Login
|
||||
av = *ptr.AvatarURL
|
||||
}
|
||||
}
|
||||
ms := noMilestone
|
||||
|
@ -152,6 +154,7 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
|
|||
l, ln := wrapLabels(v.Labels)
|
||||
ret = append(ret, githubIssue{
|
||||
Name: n,
|
||||
Avatar: av,
|
||||
Message: *v.Title,
|
||||
Date: v.CreatedAt.Format(issuesTimeFormat),
|
||||
Updated: v.UpdatedAt.Format(issuesTimeFormat),
|
||||
|
@ -197,6 +200,7 @@ func refreshIssues(gr *githubRender, config *githubConfig, client *gogithub.Clie
|
|||
sharedLabels[lab] = append(sharedLabels[lab], v.Repo)
|
||||
}
|
||||
}
|
||||
gr.HasIssues = (gr.OpenIssues + gr.ClosedIssues) > 0
|
||||
|
||||
gr.SharedLabels = make([]githubSharedLabel, 0, len(sharedLabels)) // will usually be too big
|
||||
for name, repos := range sharedLabels {
|
||||
|
@ -215,6 +219,7 @@ func refreshIssues(gr *githubRender, config *githubConfig, client *gogithub.Clie
|
|||
}
|
||||
}
|
||||
sort.Stable(sharedLabelsSort(gr.SharedLabels))
|
||||
gr.HasSharedLabels = len(gr.SharedLabels) > 0
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -165,6 +165,7 @@ func refreshMilestones(gr *githubRender, config *githubConfig, client *gogithub.
|
|||
gr.ClosedMS++
|
||||
}
|
||||
}
|
||||
gr.HasMilestones = (gr.OpenMS + gr.ClosedMS) > 0
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -29,18 +29,23 @@ type githubRender struct {
|
|||
ShowList bool `json:"showList"`
|
||||
ShowIssueNumbers bool `json:"showIssueNumbers"`
|
||||
BranchCommits []githubCommit `json:"branchCommits"`
|
||||
HasCommits bool `json:"hasCommits"`
|
||||
CommitCount int `json:"commitCount"`
|
||||
Issues []githubIssue `json:"issues"`
|
||||
HasIssues bool `json:"hasIssues"`
|
||||
SharedLabels []githubSharedLabel `json:"sharedLabels"`
|
||||
HasSharedLabels bool `json:"hasSharedLabels"`
|
||||
OpenIssues int `json:"openIssues"`
|
||||
ClosedIssues int `json:"closedIssues"`
|
||||
Limit int `json:"limit"`
|
||||
Milestones []githubMilestone `json:"milestones"`
|
||||
HasMilestones bool `json:"hasMilestones"`
|
||||
OpenMS int `json:"openMS"`
|
||||
ClosedMS int `json:"closedMS"`
|
||||
OpenPRs int `json:"openPRs"`
|
||||
ClosedPRs int `json:"closedPRs"`
|
||||
AuthorStats []githubAuthorStats `json:"authorStats"`
|
||||
HasAuthorStats bool `json:"hasAuthorStats"`
|
||||
//PullRequests []githubPullRequest `json:"pullRequests"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue