Skip to content

Commit

Permalink
Handle organization sponsor entity
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max authored and muesli committed Jun 6, 2021
1 parent bcf8e91 commit 315367c
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions sponsors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ var sponsorsQuery struct {
Node struct {
CreatedAt githubv4.DateTime
SponsorEntity struct {
SponsorUser QLUser `graphql:"... on User"`
Typename githubv4.String `graphql:"__typename"`
User QLUser `graphql:"... on User"`
Organization QLUser `graphql:"... on Organization"`
}
}
}
Expand All @@ -40,11 +42,18 @@ func sponsors(count int) []Sponsor {
// fmt.Printf("%+v\n", query)

for _, v := range sponsorsQuery.User.SponsorshipsAsMaintainer.Edges {
s := Sponsor{
User: UserFromQL(v.Node.SponsorEntity.SponsorUser),
CreatedAt: v.Node.CreatedAt.Time,
switch v.Node.SponsorEntity.Typename {
case "User":
sponsors = append(sponsors, Sponsor{
User: UserFromQL(v.Node.SponsorEntity.User),
CreatedAt: v.Node.CreatedAt.Time,
})
case "Organization":
sponsors = append(sponsors, Sponsor{
User: UserFromQL(v.Node.SponsorEntity.Organization),
CreatedAt: v.Node.CreatedAt.Time,
})
}
sponsors = append(sponsors, s)
}

// fmt.Printf("Found %d sponsors!\n", len(users))
Expand All @@ -62,11 +71,18 @@ func sponsors(count int) []Sponsor {
node {
createdAt
sponsorEntity {
__typename
... on User {
login
name
avatar
url
login
name
avatarUrl
url
}
... on Organization {
login
name
avatarUrl
url
}
}
}
Expand Down

0 comments on commit 315367c

Please sign in to comment.