Skip to content

Commit

Permalink
repos update
Browse files Browse the repository at this point in the history
  • Loading branch information
yesoreyeram committed Feb 7, 2024
1 parent 4e6bd63 commit 29330b7
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 95 deletions.
39 changes: 23 additions & 16 deletions pkg/github/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import (
)

// QueryListRepositories is the GraphQL query for retrieving a list of repositories for an organization
// {
// search(query: "is:pr repo:grafana/grafana merged:2020-08-19..*", type: ISSUE, first: 100) {
// nodes {
// ... on PullRequest {
// id
// title
// }
// }
// }
//
// {
// search(query: "is:pr repo:grafana/grafana merged:2020-08-19..*", type: ISSUE, first: 100) {
// nodes {
// ... on PullRequest {
// id
// title
// }
// }
// }
type QueryListRepositories struct {
Search struct {
Nodes []struct {
Expand All @@ -36,13 +37,15 @@ type Repository struct {
Owner struct {
Login string
}
NameWithOwner string
URL string
ForkCount int64
IsFork bool
IsMirror bool
IsPrivate bool
CreatedAt githubv4.DateTime
NameWithOwner string
URL string
ForkCount int64
StargazerCount int64 `json:"stargazerCount"`
IsFork bool
IsMirror bool
IsPrivate bool
CreatedAt githubv4.DateTime
UpdatedAt githubv4.DateTime `json:"updatedAt"`
}

// Repositories is a list of GitHub repositories
Expand All @@ -57,10 +60,12 @@ func (r Repositories) Frames() data.Frames {
data.NewField("name_with_owner", nil, []string{}),
data.NewField("url", nil, []string{}),
data.NewField("forks", nil, []int64{}),
data.NewField("stars", nil, []int64{}),
data.NewField("is_fork", nil, []bool{}),
data.NewField("is_mirror", nil, []bool{}),
data.NewField("is_private", nil, []bool{}),
data.NewField("created_at", nil, []time.Time{}),
data.NewField("updatedAt", nil, []time.Time{}),
)

for _, v := range r {
Expand All @@ -70,10 +75,12 @@ func (r Repositories) Frames() data.Frames {
v.NameWithOwner,
v.URL,
v.ForkCount,
v.StargazerCount,
v.IsFork,
v.IsMirror,
v.IsPrivate,
v.CreatedAt.Time,
v.UpdatedAt.Time,
)
}

Expand Down
22 changes: 12 additions & 10 deletions pkg/github/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,28 @@ func TestGetAllRepositories(t *testing.T) {
}

func TestRepositoriesDataFrame(t *testing.T) {
createdAt, err := time.Parse(time.RFC3339, "2020-08-25T16:21:56+00:00")
if err != nil {
t.Fatal(err)
}
createdAt, _ := time.Parse(time.RFC3339, "2020-08-25T16:21:56+00:00")
updatedAt, _ := time.Parse(time.RFC3339, "2023-08-25T16:21:56+00:00")

repositories := Repositories{
Repository{
Name: "grafana",
Owner: struct{ Login string }{
Login: "grafana",
},
NameWithOwner: "grafana/grafana",
URL: "github.com/grafana/grafana",
ForkCount: 10,
IsFork: true,
IsMirror: true,
IsPrivate: false,
NameWithOwner: "grafana/grafana",
URL: "github.com/grafana/grafana",
ForkCount: 10,
StargazerCount: 123,
IsFork: true,
IsMirror: true,
IsPrivate: false,
CreatedAt: githubv4.DateTime{
Time: createdAt,
},
UpdatedAt: githubv4.DateTime{
Time: updatedAt,
},
},
Repository{
Name: "loki",
Expand Down
16 changes: 8 additions & 8 deletions pkg/github/testdata/commits.golden.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// Frame[0]
// Name: commits
// Dimensions: 7 Fields by 2 Rows
// +----------------+-----------------+--------------------+--------------------+----------------------+---------------------------------+---------------------------------+
// | Name: id | Name: author | Name: author_login | Name: author_email | Name: author_company | Name: committed_at | Name: pushed_at |
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []time.Time | Type: []time.Time |
// +----------------+-----------------+--------------------+--------------------+----------------------+---------------------------------+---------------------------------+
// | | firstCommitter | firstCommitter | [email protected] | ACME Corp | 2020-08-25 16:21:56 +0000 +0000 | 2020-08-25 16:23:56 +0000 +0000 |
// | | secondCommitter | secondCommitter | [email protected] | ACME Corp | 2020-08-25 17:21:56 +0000 +0000 | 2020-08-25 18:21:56 +0000 +0000 |
// +----------------+-----------------+--------------------+--------------------+----------------------+---------------------------------+---------------------------------+
// +----------------+-----------------+--------------------+--------------------+----------------------+-------------------------------+-------------------------------+
// | Name: id | Name: author | Name: author_login | Name: author_email | Name: author_company | Name: committed_at | Name: pushed_at |
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []time.Time | Type: []time.Time |
// +----------------+-----------------+--------------------+--------------------+----------------------+-------------------------------+-------------------------------+
// | | firstCommitter | firstCommitter | [email protected] | ACME Corp | 2020-08-25 16:21:56 +0000 UTC | 2020-08-25 16:23:56 +0000 UTC |
// | | secondCommitter | secondCommitter | [email protected] | ACME Corp | 2020-08-25 17:21:56 +0000 UTC | 2020-08-25 18:21:56 +0000 UTC |
// +----------------+-----------------+--------------------+--------------------+----------------------+-------------------------------+-------------------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
Expand Down
18 changes: 9 additions & 9 deletions pkg/github/testdata/issues.golden.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// Frame[0]
// Name: issues
// Dimensions: 8 Fields by 3 Rows
// +----------------+----------------+----------------------+-----------------+---------------+--------------+---------------------------------+---------------------------------+
// | Name: title | Name: author | Name: author_company | Name: repo | Name: number | Name: closed | Name: created_at | Name: closed_at |
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []int64 | Type: []bool | Type: []time.Time | Type: []*time.Time |
// +----------------+----------------+----------------------+-----------------+---------------+--------------+---------------------------------+---------------------------------+
// | Issue #1 | firstUser | ACME Corp | grafana/grafana | 1 | false | 2020-08-25 16:21:56 +0000 +0000 | null |
// | Issue #2 | secondUser | ACME Corp | grafana/grafana | 2 | true | 2020-08-25 16:21:56 +0000 +0000 | 2020-08-25 22:21:56 +0000 +0000 |
// | Issue #3 | firstUser | ACME Corp | grafana/grafana | 3 | false | 2020-08-25 16:21:56 +0000 +0000 | null |
// +----------------+----------------+----------------------+-----------------+---------------+--------------+---------------------------------+---------------------------------+
// +----------------+----------------+----------------------+-----------------+---------------+--------------+-------------------------------+-------------------------------+
// | Name: title | Name: author | Name: author_company | Name: repo | Name: number | Name: closed | Name: created_at | Name: closed_at |
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []int64 | Type: []bool | Type: []time.Time | Type: []*time.Time |
// +----------------+----------------+----------------------+-----------------+---------------+--------------+-------------------------------+-------------------------------+
// | Issue #1 | firstUser | ACME Corp | grafana/grafana | 1 | false | 2020-08-25 16:21:56 +0000 UTC | null |
// | Issue #2 | secondUser | ACME Corp | grafana/grafana | 2 | true | 2020-08-25 16:21:56 +0000 UTC | 2020-08-25 22:21:56 +0000 UTC |
// | Issue #3 | firstUser | ACME Corp | grafana/grafana | 3 | false | 2020-08-25 16:21:56 +0000 UTC | null |
// +----------------+----------------+----------------------+-----------------+---------------+--------------+-------------------------------+-------------------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
Expand Down
18 changes: 9 additions & 9 deletions pkg/github/testdata/milestones.golden.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// Frame[0]
// Name: milestones
// Dimensions: 7 Fields by 3 Rows
// +------------------+----------------+--------------+----------------+---------------------------------+---------------------------------+---------------------------------+
// | Name: title | Name: author | Name: closed | Name: state | Name: created_at | Name: closed_at | Name: due_at |
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []bool | Type: []string | Type: []time.Time | Type: []*time.Time | Type: []*time.Time |
// +------------------+----------------+--------------+----------------+---------------------------------+---------------------------------+---------------------------------+
// | first milestone | testUser | false | OPEN | 2020-08-25 16:21:56 +0000 +0000 | null | 2020-08-29 20:21:56 +0000 +0000 |
// | second milestone | testUser2 | true | CLOSED | 2020-08-25 16:21:56 +0000 +0000 | 2020-08-26 02:21:56 +0000 +0000 | 2020-08-29 20:21:56 +0000 +0000 |
// | third milestone | testUser2 | false | OPEN | 2020-08-25 16:21:56 +0000 +0000 | null | 2020-08-30 16:21:56 +0000 +0000 |
// +------------------+----------------+--------------+----------------+---------------------------------+---------------------------------+---------------------------------+
// +------------------+----------------+--------------+----------------+-------------------------------+-------------------------------+-------------------------------+
// | Name: title | Name: author | Name: closed | Name: state | Name: created_at | Name: closed_at | Name: due_at |
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []bool | Type: []string | Type: []time.Time | Type: []*time.Time | Type: []*time.Time |
// +------------------+----------------+--------------+----------------+-------------------------------+-------------------------------+-------------------------------+
// | first milestone | testUser | false | OPEN | 2020-08-25 16:21:56 +0000 UTC | null | 2020-08-29 20:21:56 +0000 UTC |
// | second milestone | testUser2 | true | CLOSED | 2020-08-25 16:21:56 +0000 UTC | 2020-08-26 02:21:56 +0000 UTC | 2020-08-29 20:21:56 +0000 UTC |
// | third milestone | testUser2 | false | OPEN | 2020-08-25 16:21:56 +0000 UTC | null | 2020-08-30 16:21:56 +0000 UTC |
// +------------------+----------------+--------------+----------------+-------------------------------+-------------------------------+-------------------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
Expand Down
Loading

0 comments on commit 29330b7

Please sign in to comment.