Skip to content

Commit

Permalink
Merge pull request #61 from moul/dev/moul/pull-caching
Browse files Browse the repository at this point in the history
feat: pull caching (#60)
  • Loading branch information
moul authored Sep 23, 2018
2 parents c53babb + 323582f commit 5eae81d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,16 @@ func pull(opts *pullOptions) error {
client := github.NewClient(tc)

go func(repo Repo) {

total := 0
defer wg.Done()
opts := &github.IssueListByRepoOptions{State: "all"}

var lastEntry Issue
if err := db.Where("repo_url = ?", repo.Canonical()).Order("updated_at desc").First(&lastEntry).Error; err == nil {
opts.Since = lastEntry.UpdatedAt
}

for {
issues, resp, err := client.Issues.ListByRepo(ctx, repo.Namespace(), repo.Project(), opts)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"regexp"
"strconv"
"strings"
"time"

"github.com/awalterschulze/gographviz"
"github.com/google/go-github/github"
Expand Down Expand Up @@ -44,6 +45,8 @@ type Issue struct {
Errors []error `json:"-" gorm:"-"`

// mapping
CreatedAt time.Time
UpdatedAt time.Time
Number int
Title string
State string
Expand Down Expand Up @@ -72,6 +75,8 @@ func FromGitHubIssue(input *github.Issue) *Issue {
}
parts := strings.Split(*input.HTMLURL, "/")
issue := &Issue{
CreatedAt: *input.CreatedAt,
UpdatedAt: *input.UpdatedAt,
Provider: GitHubProvider,
GitHub: input,
Number: *input.Number,
Expand Down

0 comments on commit 5eae81d

Please sign in to comment.