Sha256: bf6435935e795dca9758b2e054a546e5afe0d2ac40fc6898457966a7fe764b7c

Contents?: true

Size: 644 Bytes

Versions: 1

Compression:

Stored size: 644 Bytes

Contents

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

module HubLink
  class Stream
    GITHUB_BATCH_SIZE = 14

    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

1 entries across 1 versions & 1 rubygems

Version Path
hub_link-0.4.0 lib/hub_link/stream.rb