Skip to content

Commit

Permalink
fix: make 'pull' nonblocking (supporting more than 100 new issues)
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jul 22, 2019
1 parent 0b1e427 commit 76904b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/issues/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func githubPull(target Target, wg *sync.WaitGroup, token string, db *gorm.DB, ou
if err := db.Where("repository_id = ?", target.ProjectURL()).Order("updated_at desc").First(&lastEntry).Error; err == nil {
callOpts.Since = lastEntry.UpdatedAt
} else {
zap.L().Warn("failed to get last entry", zap.Error(err))
zap.L().Warn("failed to get last entry", zap.String("repo", target.ProjectURL()), zap.Error(err))
}

for {
Expand Down
8 changes: 6 additions & 2 deletions pkg/issues/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ func PullAndCompute(githubToken, gitlabToken string, db *gorm.DB, t Targets) err
panic("should not happen")
}
}
wg.Wait()
close(out)

go func() {
wg.Wait()
close(out)
}()

for issues := range out {
allIssues = append(allIssues, issues...)
}
Expand Down

0 comments on commit 76904b7

Please sign in to comment.