Skip to content

Commit

Permalink
Don't count views creation time as data fetching
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Sukharev <[email protected]>
  • Loading branch information
smacker committed Oct 23, 2019
1 parent a1cb17d commit 0dc847a
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions examples/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,6 @@ func (c *DownloaderCmd) ExecuteBody(logger log.Logger, fn bodyFunc) error {
return err
}

err = c.commit(ctx, downloadersPool)
if err != nil {
return err
}

stats, err := downloadersPool.End(ctx)

logger.With(log.Fields{"total-elapsed": stats.Elapsed}).Infof("all metadata fetched")
Expand All @@ -293,23 +288,31 @@ func (c *DownloaderCmd) ExecuteBody(logger log.Logger, fn bodyFunc) error {
}).Infof("token usage")
}

d, err := github.NewDownloader(nil, storer)
if err != nil {
return err
}

err = c.commit(ctx, d)
if err != nil {
return err
}

return nil
}

func (c *DownloaderCmd) commit(ctx context.Context, dp *DownloadersPool) error {
return dp.WithDownloader(func(d *github.Downloader) error {
var err error
err = d.SetCurrent(ctx, c.Version)
if err != nil {
return err
}
func (c *DownloaderCmd) commit(ctx context.Context, d *github.Downloader) error {
var err error
err = d.SetCurrent(ctx, c.Version)
if err != nil {
return err
}

if c.Cleanup {
return d.Cleanup(ctx, c.Version)
}
if c.Cleanup {
return d.Cleanup(ctx, c.Version)
}

return nil
})
return nil
}

func (c *DownloaderCmd) buildDownloadersPool(logger log.Logger, storer github.Storer) (*DownloadersPool, error) {
Expand Down

0 comments on commit 0dc847a

Please sign in to comment.