mirror of
https://github.com/documize/community.git
synced 2025-07-22 14:49:42 +02:00
Add issue creator real names
This commit is contained in:
parent
049ff73825
commit
b419bd2d52
4 changed files with 34 additions and 21 deletions
|
@ -171,26 +171,7 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubCommit,
|
||||||
if v.Author != nil {
|
if v.Author != nil {
|
||||||
if v.Author.Login != nil {
|
if v.Author.Login != nil {
|
||||||
al = *v.Author.Login
|
al = *v.Author.Login
|
||||||
an = al
|
an = getUserName(client, config, al)
|
||||||
|
|
||||||
if content, found := config.UserNames[al]; found {
|
|
||||||
if len(content) > 0 {
|
|
||||||
an = content
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
usr, _, err := client.Users.Get(al)
|
|
||||||
if err == nil {
|
|
||||||
if usr.Name != nil {
|
|
||||||
if len(*usr.Name) > 0 {
|
|
||||||
config.UserNames[al] = *usr.Name
|
|
||||||
an = *usr.Name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
config.UserNames[al] = al // don't look again for a missing name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.Author.AvatarURL != nil {
|
if v.Author.AvatarURL != nil {
|
||||||
|
@ -315,6 +296,8 @@ func renderCommits(payload *githubRender, c *githubConfig) error {
|
||||||
payload.HasAuthorStats = len(payload.AuthorStats) > 0
|
payload.HasAuthorStats = len(payload.AuthorStats) > 0
|
||||||
sort.Sort(asToSort(payload.AuthorStats))
|
sort.Sort(asToSort(payload.AuthorStats))
|
||||||
|
|
||||||
|
payload.NumContributors = len(payload.AuthorStats) - 1
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ type githubIssue struct {
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
URL template.URL `json:"url"`
|
URL template.URL `json:"url"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
Creator string `json:"creator"`
|
||||||
Avatar string `json:"avatar"`
|
Avatar string `json:"avatar"`
|
||||||
Labels template.HTML `json:"labels"`
|
Labels template.HTML `json:"labels"`
|
||||||
LabelNames []string `json:"labelNames"`
|
LabelNames []string `json:"labelNames"`
|
||||||
|
@ -152,6 +153,7 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
|
||||||
l, ln, lc := wrapLabels(v.Labels)
|
l, ln, lc := wrapLabels(v.Labels)
|
||||||
ret = append(ret, githubIssue{
|
ret = append(ret, githubIssue{
|
||||||
Name: n,
|
Name: n,
|
||||||
|
Creator: getUserName(client, config, *v.User.Login),
|
||||||
Avatar: av,
|
Avatar: av,
|
||||||
Message: *v.Title,
|
Message: *v.Title,
|
||||||
Date: v.CreatedAt.Format(issuesTimeFormat),
|
Date: v.CreatedAt.Format(issuesTimeFormat),
|
||||||
|
|
|
@ -73,7 +73,7 @@ const (
|
||||||
|
|
||||||
<td style="width:40%;">
|
<td style="width:40%;">
|
||||||
<h6>{{$data.Repo}}</h6> <br>
|
<h6>{{$data.Repo}}</h6> <br>
|
||||||
<span class="date-meta">opened on {{$data.Date}} by {{$data.Name}}</span>
|
<span class="date-meta">{{$data.Creator}} opened on {{$data.Date}}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -45,6 +45,7 @@ type githubRender struct {
|
||||||
ClosedPRs int `json:"closedPRs"`
|
ClosedPRs int `json:"closedPRs"`
|
||||||
AuthorStats []githubAuthorStats `json:"authorStats"`
|
AuthorStats []githubAuthorStats `json:"authorStats"`
|
||||||
HasAuthorStats bool `json:"hasAuthorStats"`
|
HasAuthorStats bool `json:"hasAuthorStats"`
|
||||||
|
NumContributors int `json:"numContributors"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type report struct {
|
type report struct {
|
||||||
|
@ -139,6 +140,11 @@ func (c *githubConfig) Clean() {
|
||||||
if lastItem < len(c.Lists) {
|
if lastItem < len(c.Lists) {
|
||||||
c.Lists[lastItem].Comma = false
|
c.Lists[lastItem].Comma = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.UserNames == nil {
|
||||||
|
c.UserNames = make(map[string]string)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type githubCallbackT struct {
|
type githubCallbackT struct {
|
||||||
|
@ -156,3 +162,25 @@ func repoName(branchName string) string {
|
||||||
}
|
}
|
||||||
return pieces[0]
|
return pieces[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getUserName(client *gogithub.Client, config *githubConfig, login string) (fullName string) {
|
||||||
|
an := login
|
||||||
|
if content, found := config.UserNames[login]; found {
|
||||||
|
if len(content) > 0 {
|
||||||
|
an = content
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
usr, _, err := client.Users.Get(login)
|
||||||
|
if err == nil {
|
||||||
|
if usr.Name != nil {
|
||||||
|
if len(*usr.Name) > 0 {
|
||||||
|
config.UserNames[login] = *usr.Name
|
||||||
|
an = *usr.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
config.UserNames[login] = login // don't look again for a missing name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return an
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue