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

feat(Pull Request): Additions and Deletions #400

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions pkg/github/pull_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type PullRequest struct {
Number int64
Title string
URL string
Additions int64
Deletions int64
State githubv4.PullRequestState
Author PullRequestAuthor
Closed bool
Expand Down Expand Up @@ -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{}),
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions pkg/github/pull_requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
44 changes: 34 additions & 10 deletions pkg/github/testdata/pull_requests.golden.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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. 🌟
Expand Down Expand Up @@ -43,6 +43,20 @@
"frame": "string"
}
},
{
"name": "additions",
"type": "number",
"typeInfo": {
"frame": "int64"
}
},
{
"name": "deletions",
"type": "number",
"typeInfo": {
"frame": "int64"
}
},
{
"name": "repository",
"type": "string",
Expand Down Expand Up @@ -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",
Expand Down