diff --git a/pkg/github/pull_requests.go b/pkg/github/pull_requests.go index 5f69eff9..fc0db82d 100644 --- a/pkg/github/pull_requests.go +++ b/pkg/github/pull_requests.go @@ -42,6 +42,8 @@ type PullRequest struct { Number int64 Title string URL string + Additions int64 + Deletions int64 State githubv4.PullRequestState Author PullRequestAuthor Closed bool @@ -72,6 +74,8 @@ func (p PullRequests) Frames() data.Frames { data.NewField("number", nil, []int64{}), data.NewField("title", nil, []string{}), data.NewField("url", nil, []string{}), + data.NewField("additions", nil, []int64{}), + data.NewField("deletions", nil, []int64{}), data.NewField("repository", nil, []string{}), data.NewField("state", nil, []string{}), data.NewField("author_name", nil, []string{}), @@ -150,6 +154,8 @@ func (p PullRequests) Frames() data.Frames { v.Number, v.Title, v.URL, + v.Additions, + v.Deletions, v.Repository.NameWithOwner, string(v.State), v.Author.User.Name, diff --git a/pkg/github/pull_requests_test.go b/pkg/github/pull_requests_test.go index 54c97a16..135fe8ff 100644 --- a/pkg/github/pull_requests_test.go +++ b/pkg/github/pull_requests_test.go @@ -66,10 +66,12 @@ func TestPullRequestsDataFrame(t *testing.T) { Repository: Repository{ NameWithOwner: "grafana/github-datasource", }, - Closed: true, - IsDraft: false, - Locked: false, - Merged: true, + Closed: true, + IsDraft: false, + Locked: false, + Merged: true, + Additions: 5, + Deletions: 1, CreatedAt: githubv4.DateTime{ Time: openedAt, }, diff --git a/pkg/github/testdata/pull_requests.golden.jsonc b/pkg/github/testdata/pull_requests.golden.jsonc index 40b8da92..3e695b68 100644 --- a/pkg/github/testdata/pull_requests.golden.jsonc +++ b/pkg/github/testdata/pull_requests.golden.jsonc @@ -2,16 +2,16 @@ // // Frame[0] // Name: pull_requests -// Dimensions: 23 Fields by 3 Rows -// +---------------+----------------+------------------------------------------------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+ -// | Name: number | Name: title | Name: url | Name: repository | Name: state | Name: author_name | Name: author_login | Name: author_email | Name: author_company | Name: closed | Name: is_draft | Name: locked | Name: merged | Name: mergeable | Name: closed_at | Name: merged_at | Name: merged_by_name | Name: merged_by_login | Name: merged_by_email | Name: merged_by_company | Name: updated_at | Name: created_at | Name: open_time | -// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | -// | Type: []int64 | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []bool | Type: []bool | Type: []bool | Type: []bool | Type: []string | Type: []*time.Time | Type: []*time.Time | Type: []*string | Type: []*string | Type: []*string | Type: []*string | Type: []time.Time | Type: []time.Time | Type: []float64 | -// +---------------+----------------+------------------------------------------------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+ -// | 1 | PullRequest #1 | https://github.com/grafana/github-datasource/pulls/1 | grafana/github-datasource | OPEN | Test User | testUser | user@example.com | ACME corp | true | false | false | true | MERGEABLE | 2020-08-25 18:01:56 +0000 +0000 | 2020-08-25 18:01:56 +0000 +0000 | null | null | null | null | 2020-08-25 16:21:56 +0000 +0000 | 2020-08-25 16:21:56 +0000 +0000 | 6000 | -// | 2 | PullRequest #2 | https://github.com/grafana/github-datasource/pulls/2 | grafana/github-datasource | OPEN | Second User | testUser2 | user2@example.com | ACME corp | true | false | false | true | MERGEABLE | 2020-08-25 18:01:56 +0000 +0000 | 2020-08-25 18:01:56 +0000 +0000 | Test User | testUser | user@example.com | ACME corp | 2020-08-25 18:21:56 +0000 +0000 | 2020-08-25 16:21:56 +0000 +0000 | 6000 | -// | 3 | PullRequest #2 | https://github.com/grafana/github-datasource/pulls/3 | grafana/github-datasource | OPEN | Second User | testUser2 | user2@example.com | ACME corp | false | false | false | false | MERGEABLE | null | 2020-08-25 18:01:56 +0000 +0000 | null | null | null | null | 2020-08-25 18:21:56 +0000 +0000 | 2020-08-25 16:21:56 +0000 +0000 | 6000 | -// +---------------+----------------+------------------------------------------------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+ +// Dimensions: 25 Fields by 3 Rows +// +---------------+----------------+------------------------------------------------------+-----------------+-----------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+ +// | Name: number | Name: title | Name: url | Name: additions | Name: deletions | Name: repository | Name: state | Name: author_name | Name: author_login | Name: author_email | Name: author_company | Name: closed | Name: is_draft | Name: locked | Name: merged | Name: mergeable | Name: closed_at | Name: merged_at | Name: merged_by_name | Name: merged_by_login | Name: merged_by_email | Name: merged_by_company | Name: updated_at | Name: created_at | Name: open_time | +// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | +// | Type: []int64 | Type: []string | Type: []string | Type: []int64 | Type: []int64 | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []bool | Type: []bool | Type: []bool | Type: []bool | Type: []string | Type: []*time.Time | Type: []*time.Time | Type: []*string | Type: []*string | Type: []*string | Type: []*string | Type: []time.Time | Type: []time.Time | Type: []float64 | +// +---------------+----------------+------------------------------------------------------+-----------------+-----------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+ +// | 1 | PullRequest #1 | https://github.com/grafana/github-datasource/pulls/1 | 5 | 1 | grafana/github-datasource | OPEN | Test User | testUser | user@example.com | ACME corp | true | false | false | true | MERGEABLE | 2020-08-25 18:01:56 +0000 +0000 | 2020-08-25 18:01:56 +0000 +0000 | null | null | null | null | 2020-08-25 16:21:56 +0000 +0000 | 2020-08-25 16:21:56 +0000 +0000 | 6000 | +// | 2 | PullRequest #2 | https://github.com/grafana/github-datasource/pulls/2 | 0 | 0 | grafana/github-datasource | OPEN | Second User | testUser2 | user2@example.com | ACME corp | true | false | false | true | MERGEABLE | 2020-08-25 18:01:56 +0000 +0000 | 2020-08-25 18:01:56 +0000 +0000 | Test User | testUser | user@example.com | ACME corp | 2020-08-25 18:21:56 +0000 +0000 | 2020-08-25 16:21:56 +0000 +0000 | 6000 | +// | 3 | PullRequest #2 | https://github.com/grafana/github-datasource/pulls/3 | 0 | 0 | grafana/github-datasource | OPEN | Second User | testUser2 | user2@example.com | ACME corp | false | false | false | false | MERGEABLE | null | 2020-08-25 18:01:56 +0000 +0000 | null | null | null | null | 2020-08-25 18:21:56 +0000 +0000 | 2020-08-25 16:21:56 +0000 +0000 | 6000 | +// +---------------+----------------+------------------------------------------------------+-----------------+-----------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+ // // // 🌟 This was machine generated. Do not edit. 🌟 @@ -43,6 +43,20 @@ "frame": "string" } }, + { + "name": "additions", + "type": "number", + "typeInfo": { + "frame": "int64" + } + }, + { + "name": "deletions", + "type": "number", + "typeInfo": { + "frame": "int64" + } + }, { "name": "repository", "type": "string", @@ -211,6 +225,16 @@ "https://github.com/grafana/github-datasource/pulls/2", "https://github.com/grafana/github-datasource/pulls/3" ], + [ + 5, + 0, + 0 + ], + [ + 1, + 0, + 0 + ], [ "grafana/github-datasource", "grafana/github-datasource",