Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contributions #11

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions template/userlist.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

Last updated: {{ .Updated }}

| # | GitHub Login | GitHub name | E-Mail |
| --- | --- | --- | --- |
{{ range .Users }} | {{ .Number }} | [{{ .Login }}](https://github.com/enterprises/{{ $.Enterprise.Slug }}/people/{{ .Login }}/sso) | {{ .Name }} | {{ .Email }} |
{{end}}
| # | GitHub Login | GitHub name | E-Mail | Contributions |
| --- | --- | --- | --- | --- |
{{ range .Users }} | {{ .Number }} | [{{ .Login }}](https://github.com/enterprises/{{ $.Enterprise.Slug }}/people/{{ .Login }}/sso) | {{ .Name }} | {{ .Email }} | {{if .Contributions}}:green_square:{{else}}:red_square:{{end}} {{.Contributions }} |
{{ end }}

{{ if .Users }}_{{ len .Users }} users_{{ else }}No users found.{{ end }}

---
Generated with :heart: by [github-users](https://github.com/prodyna/github-users)
34 changes: 16 additions & 18 deletions userlist/userlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ type Enterprise struct {
}

type User struct {
Number int `json:"Number"`
Login string `json:"Login"`
Name string `json:"Name"`
Email string `json:"Email"`
Organizations []Organization `json:"Organizations"`
Number int `json:"Number"`
Login string `json:"Login"`
Name string `json:"Name"`
Email string `json:"Email"`
Contributions int `json:"Contributions"`
}

type Organization struct {
Expand Down Expand Up @@ -140,13 +140,13 @@ func (c *UserListConfig) Load() error {
Edges []struct {
Node struct {
User struct {
Login string
Name string
Organizations struct {
Nodes []struct {
Name string
Login string
Name string
ContributionsCollection struct {
ContributionCalendar struct {
TotalContributions int
}
} `graphql:"organizations(first: 10)"`
}
}
SamlIdentity struct {
NameId string
Expand Down Expand Up @@ -179,13 +179,11 @@ func (c *UserListConfig) Load() error {

for i, e := range query.Enterprise.OwnerInfo.SamlIdentityProvider.ExternalIdentities.Edges {
u := User{
Number: offset + i + 1,
Login: e.Node.User.Login,
Name: e.Node.User.Name,
Email: e.Node.SamlIdentity.NameId,
}
for _, o := range e.Node.User.Organizations.Nodes {
u.Organizations = append(u.Organizations, Organization{Name: o.Name})
Number: offset + i + 1,
Login: e.Node.User.Login,
Name: e.Node.User.Name,
Email: e.Node.SamlIdentity.NameId,
Contributions: e.Node.User.ContributionsCollection.ContributionCalendar.TotalContributions,
}
c.userList.Users = append(c.userList.Users, u)
}
Expand Down