Sha256: 4126c31ee3da873c00443fff027b05daf2f66b79b4c0c03a06c7cf14fec6cb7f

Contents?: true

Size: 649 Bytes

Versions: 2

Compression:

Stored size: 649 Bytes

Contents

require "hub_link/api/pull_request"
require "hub_link/batch"

module HubLink
  class Stream
    GITHUB_BATCH_SIZE = 1 # Day

    def initialize(repo, start_date: 2.years.ago)
      @repo = repo
      @start_date = start_date.to_date
    end

    def in_batches(&block)
      queries.each do |query|
        yield Batch.new(query)
      end
    end

    private

      attr_accessor :repo, :start_date

      def queries
        start_date.step(end_date, GITHUB_BATCH_SIZE).map do |date|
          "type:pr updated:#{date}..#{date + GITHUB_BATCH_SIZE} repo:#{repo}"
        end
      end

      def end_date
        Date.tomorrow
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hub_link-0.6.0 lib/hub_link/stream.rb
hub_link-0.5.0 lib/hub_link/stream.rb