Skip to content

Commit

Permalink
feat: add 'Completed' field in Airtable
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Oct 15, 2018
1 parent 4fa05af commit d5448bc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
3 changes: 3 additions & 0 deletions cmd_airtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -211,6 +212,7 @@ type airtableIssue struct {
URL string
Created time.Time
Updated time.Time
Completed time.Time
Title string
Provider string
State string
Expand Down Expand Up @@ -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 &&
Expand Down
58 changes: 30 additions & 28 deletions issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d5448bc

Please sign in to comment.