Skip to content

Commit

Permalink
Feat: Add updated_at field to issues (#313) (#315)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivana Huckova <[email protected]>
  • Loading branch information
I558191 and ivanahuckova authored Jun 18, 2024
1 parent 67b63ed commit 91f4c5a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
3 changes: 3 additions & 0 deletions pkg/github/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Issue struct {
Title string
ClosedAt githubv4.DateTime
CreatedAt githubv4.DateTime
UpdatedAt githubv4.DateTime
Closed bool
Author struct {
models.User `graphql:"... on User"`
Expand All @@ -40,6 +41,7 @@ func (c Issues) Frames() data.Frames {
data.NewField("closed", nil, []bool{}),
data.NewField("created_at", nil, []time.Time{}),
data.NewField("closed_at", nil, []*time.Time{}),
data.NewField("updated_at", nil, []time.Time{}),
)

for _, v := range c {
Expand All @@ -58,6 +60,7 @@ func (c Issues) Frames() data.Frames {
v.Closed,
v.CreatedAt.Time,
closedAt,
v.UpdatedAt.Time,
)
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/github/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func TestIssuesDataframe(t *testing.T) {
CreatedAt: githubv4.DateTime{
Time: createdAt,
},
UpdatedAt: githubv4.DateTime{
Time: createdAt,
},
Closed: false,
Author: struct {
models.User "graphql:\"... on User\""
Expand Down Expand Up @@ -87,6 +90,9 @@ func TestIssuesDataframe(t *testing.T) {
CreatedAt: githubv4.DateTime{
Time: createdAt,
},
UpdatedAt: githubv4.DateTime{
Time: createdAt.Add(time.Hour * 6),
},
Closed: true,
Author: struct {
models.User "graphql:\"... on User\""
Expand Down Expand Up @@ -125,6 +131,9 @@ func TestIssuesDataframe(t *testing.T) {
CreatedAt: githubv4.DateTime{
Time: createdAt,
},
UpdatedAt: githubv4.DateTime{
Time: createdAt,
},
Closed: false,
Author: struct {
models.User "graphql:\"... on User\""
Expand Down
32 changes: 22 additions & 10 deletions pkg/github/testdata/issues.golden.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
//
// 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 |
// +----------------+----------------+----------------------+-----------------+---------------+--------------+---------------------------------+---------------------------------+
// Dimensions: 9 Fields by 3 Rows
// +----------------+----------------+----------------------+-----------------+---------------+--------------+---------------------------------+---------------------------------+---------------------------------+
// | Name: title | Name: author | Name: author_company | Name: repo | Name: number | Name: closed | Name: created_at | Name: closed_at | Name: updated_at |
// | Labels: | 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 | Type: []time.Time |
// +----------------+----------------+----------------------+-----------------+---------------+--------------+---------------------------------+---------------------------------+---------------------------------+
// | Issue #1 | firstUser | ACME Corp | grafana/grafana | 1 | false | 2020-08-25 16:21:56 +0000 +0000 | null | 2020-08-25 16:21:56 +0000 +0000 |
// | 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 | 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 | 2020-08-25 16:21:56 +0000 +0000 |
// +----------------+----------------+----------------------+-----------------+---------------+--------------+---------------------------------+---------------------------------+---------------------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
Expand Down Expand Up @@ -78,6 +78,13 @@
"frame": "time.Time",
"nullable": true
}
},
{
"name": "updated_at",
"type": "time",
"typeInfo": {
"frame": "time.Time"
}
}
]
},
Expand Down Expand Up @@ -122,6 +129,11 @@
null,
1598394116000,
null
],
[
1598372516000,
1598394116000,
1598372516000
]
]
}
Expand Down

0 comments on commit 91f4c5a

Please sign in to comment.