Skip to content

Commit fa9f66e

Browse files
authored
feat(Pull Request): Additions and Deletions (#400)
1 parent f690668 commit fa9f66e

File tree

3 files changed

+46
-14
lines changed

3 files changed

+46
-14
lines changed

pkg/github/pull_requests.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ type PullRequest struct {
4242
Number int64
4343
Title string
4444
URL string
45+
Additions int64
46+
Deletions int64
4547
State githubv4.PullRequestState
4648
Author PullRequestAuthor
4749
Closed bool
@@ -72,6 +74,8 @@ func (p PullRequests) Frames() data.Frames {
7274
data.NewField("number", nil, []int64{}),
7375
data.NewField("title", nil, []string{}),
7476
data.NewField("url", nil, []string{}),
77+
data.NewField("additions", nil, []int64{}),
78+
data.NewField("deletions", nil, []int64{}),
7579
data.NewField("repository", nil, []string{}),
7680
data.NewField("state", nil, []string{}),
7781
data.NewField("author_name", nil, []string{}),
@@ -150,6 +154,8 @@ func (p PullRequests) Frames() data.Frames {
150154
v.Number,
151155
v.Title,
152156
v.URL,
157+
v.Additions,
158+
v.Deletions,
153159
v.Repository.NameWithOwner,
154160
string(v.State),
155161
v.Author.User.Name,

pkg/github/pull_requests_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ func TestPullRequestsDataFrame(t *testing.T) {
6666
Repository: Repository{
6767
NameWithOwner: "grafana/github-datasource",
6868
},
69-
Closed: true,
70-
IsDraft: false,
71-
Locked: false,
72-
Merged: true,
69+
Closed: true,
70+
IsDraft: false,
71+
Locked: false,
72+
Merged: true,
73+
Additions: 5,
74+
Deletions: 1,
7375
CreatedAt: githubv4.DateTime{
7476
Time: openedAt,
7577
},

pkg/github/testdata/pull_requests.golden.jsonc

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
//
33
// Frame[0]
44
// Name: pull_requests
5-
// Dimensions: 23 Fields by 3 Rows
6-
// +---------------+----------------+------------------------------------------------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+
7-
// | 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 |
8-
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
9-
// | 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 |
10-
// +---------------+----------------+------------------------------------------------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+
11-
// | 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 |
12-
// | 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 |
13-
// | 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 |
14-
// +---------------+----------------+------------------------------------------------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+
5+
// Dimensions: 25 Fields by 3 Rows
6+
// +---------------+----------------+------------------------------------------------------+-----------------+-----------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+
7+
// | 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 |
8+
// | 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: |
9+
// | 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 |
10+
// +---------------+----------------+------------------------------------------------------+-----------------+-----------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+
11+
// | 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 |
12+
// | 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 |
13+
// | 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 |
14+
// +---------------+----------------+------------------------------------------------------+-----------------+-----------------+---------------------------+----------------+-------------------+--------------------+--------------------+----------------------+--------------+----------------+--------------+--------------+-----------------+---------------------------------+---------------------------------+----------------------+-----------------------+-----------------------+-------------------------+---------------------------------+---------------------------------+-----------------+
1515
//
1616
//
1717
// 🌟 This was machine generated. Do not edit. 🌟
@@ -43,6 +43,20 @@
4343
"frame": "string"
4444
}
4545
},
46+
{
47+
"name": "additions",
48+
"type": "number",
49+
"typeInfo": {
50+
"frame": "int64"
51+
}
52+
},
53+
{
54+
"name": "deletions",
55+
"type": "number",
56+
"typeInfo": {
57+
"frame": "int64"
58+
}
59+
},
4660
{
4761
"name": "repository",
4862
"type": "string",
@@ -211,6 +225,16 @@
211225
"https://github.com/grafana/github-datasource/pulls/2",
212226
"https://github.com/grafana/github-datasource/pulls/3"
213227
],
228+
[
229+
5,
230+
0,
231+
0
232+
],
233+
[
234+
1,
235+
0,
236+
0
237+
],
214238
[
215239
"grafana/github-datasource",
216240
"grafana/github-datasource",

0 commit comments

Comments
 (0)