Class: Codeclimate::Collectors::Pagerduty::Handlers::Sync

Inherits:
Handler
  • Object
show all
Defined in:
lib/codeclimate/collectors/pagerduty/handlers/sync.rb

Constant Summary collapse

LIMIT =
100

Instance Method Summary collapse

Constructor Details

#initialize(configuration:, manager:, earliest_data_cutoff:) ⇒ Sync

Returns a new instance of Sync.



8
9
10
11
# File 'lib/codeclimate/collectors/pagerduty/handlers/sync.rb', line 8

def initialize(configuration:, manager:, earliest_data_cutoff:)
  super(configuration: configuration, manager: manager)
  @earliest_data_cutoff = earliest_data_cutoff
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/codeclimate/collectors/pagerduty/handlers/sync.rb', line 13

def run
  page = 1
  has_more = true

  while has_more
    page_data = fetch_page(page)

    page_data["incidents"].each do |incident_json|
      process_incident(incident_json)
    end

    has_more = page_data["more"]
    page += 1
  end
end