Class: Chronicle::Github::ActivityExtractor

Inherits:
ETL::Extractor
  • Object
show all
Defined in:
lib/chronicle/github/activity_extractor.rb

Instance Method Summary collapse

Instance Method Details

#extractObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/chronicle/github/activity_extractor.rb', line 22

def extract
  events = @client.user_events(username)
  has_more = events.any?
  count = 0

  while has_more
    events = events.first(@config.limit - count) if @config.limit
    events = events.filter { |event| event.created_at > @config.since } if @config.since

    break unless events.any?

    events.each do |event|
      count += 1
      yield build_extraction(data: event, meta: { user: @user })
    end

    break unless @client.last_response.rels[:next]

    events = @client.get(@client.last_response.rels[:next].href)
    has_more = events.any?
  end
end

#prepareObject



17
18
19
20
# File 'lib/chronicle/github/activity_extractor.rb', line 17

def prepare
  @client = ::Octokit::Client.new(access_token: @config.access_token)
  @access_token_owner = @client.user
end