From 0dc847a7e8b46e58c42dcc1ab03d760dd9e5dfb9 Mon Sep 17 00:00:00 2001 From: Maxim Sukharev Date: Wed, 23 Oct 2019 13:32:24 +0200 Subject: [PATCH] Don't count views creation time as data fetching Signed-off-by: Maxim Sukharev --- examples/cmd/main.go | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/examples/cmd/main.go b/examples/cmd/main.go index f3d4407..a9ce695 100644 --- a/examples/cmd/main.go +++ b/examples/cmd/main.go @@ -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") @@ -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) {