From d5448bcadfec4e625795d21ee5e16c311a497166 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 15 Oct 2018 22:21:21 +0200 Subject: [PATCH] feat: add 'Completed' field in Airtable --- cmd_airtable.go | 3 +++ issue.go | 58 +++++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/cmd_airtable.go b/cmd_airtable.go index 8dae09fa1..8e5f82635 100644 --- a/cmd_airtable.go +++ b/cmd_airtable.go @@ -188,6 +188,7 @@ func (i Issue) ToAirtableRecord() airtableRecord { URL: i.URL, Created: i.CreatedAt, Updated: i.UpdatedAt, + Completed: i.CompletedAt, Title: i.Title, Type: typ, Labels: labels, @@ -211,6 +212,7 @@ type airtableIssue struct { URL string Created time.Time Updated time.Time + Completed time.Time Title string Provider string State string @@ -248,6 +250,7 @@ func (ai airtableIssue) Equals(other airtableIssue) bool { return ai.URL == other.URL && ai.Created.Truncate(time.Millisecond).UTC() == other.Created.Truncate(time.Millisecond).UTC() && ai.Updated.Truncate(time.Millisecond).UTC() == other.Updated.Truncate(time.Millisecond).UTC() && + ai.Completed.Truncate(time.Millisecond).UTC() == other.Completed.Truncate(time.Millisecond).UTC() && ai.Title == other.Title && ai.Provider == other.Provider && ai.State == other.State && diff --git a/issue.go b/issue.go index 60349a0af..a4c9fc994 100644 --- a/issue.go +++ b/issue.go @@ -45,17 +45,18 @@ type Issue struct { Errors []error `json:"-" gorm:"-"` // mapping - CreatedAt time.Time - UpdatedAt time.Time - Number int - Title string - State string - Body string - RepoURL string - URL string `gorm:"primary_key"` - Labels []*IssueLabel `gorm:"many2many:issue_labels;"` - Assignees []*Profile `gorm:"many2many:issue_assignees;"` - IsPR bool + CreatedAt time.Time + UpdatedAt time.Time + CompletedAt time.Time + Number int + Title string + State string + Body string + RepoURL string + URL string `gorm:"primary_key"` + Labels []*IssueLabel `gorm:"many2many:issue_labels;"` + Assignees []*Profile `gorm:"many2many:issue_assignees;"` + IsPR bool Locked bool Author Profile @@ -87,23 +88,24 @@ func FromGitHubIssue(input *github.Issue) *Issue { authorName = *input.User.Name } issue := &Issue{ - CreatedAt: *input.CreatedAt, - UpdatedAt: *input.UpdatedAt, - Provider: GitHubProvider, - GitHub: input, - Number: *input.Number, - Title: *input.Title, - State: *input.State, - Body: body, - IsPR: input.PullRequestLinks != nil, - URL: strings.Replace(*input.HTMLURL, "/pull/", "/issues/", -1), - RepoURL: strings.Join(parts[0:len(parts)-2], "/"), - Labels: make([]*IssueLabel, 0), - Assignees: make([]*Profile, 0), - Locked: *input.Locked, - Comments: *input.Comments, - Upvotes: *input.Reactions.PlusOne, - Downvotes: *input.Reactions.MinusOne, + CreatedAt: *input.CreatedAt, + UpdatedAt: *input.UpdatedAt, + CompletedAt: input.GetClosedAt(), + Provider: GitHubProvider, + GitHub: input, + Number: *input.Number, + Title: *input.Title, + State: *input.State, + Body: body, + IsPR: input.PullRequestLinks != nil, + URL: strings.Replace(*input.HTMLURL, "/pull/", "/issues/", -1), + RepoURL: strings.Join(parts[0:len(parts)-2], "/"), + Labels: make([]*IssueLabel, 0), + Assignees: make([]*Profile, 0), + Locked: *input.Locked, + Comments: *input.Comments, + Upvotes: *input.Reactions.PlusOne, + Downvotes: *input.Reactions.MinusOne, Author: Profile{ ID: *input.User.Login, Name: authorName,