lib/flapjack/gateways/jsonapi/check_presenter.rb in flapjack-0.9.6 vs lib/flapjack/gateways/jsonapi/check_presenter.rb in flapjack-1.0.0rc1

- old
+ new

@@ -79,11 +79,11 @@ :summary => obj[:summary] || '', :details => obj[:details] || '' } end - {:outages => result} + result end def unscheduled_maintenance(start_time, end_time) # unsched_maintenance is an array of hashes, with [duration, timestamp, summary] keys unsched_maintenance = @entity_check.maintenances(start_time, end_time, @@ -94,11 +94,11 @@ start_in_unsched = start_time.nil? ? [] : @entity_check.maintenances(nil, start_time, :scheduled => false).select {|pu| pu[:end_time] >= start_time } - {:unscheduled_maintenances => (start_in_unsched + unsched_maintenance)} + start_in_unsched + unsched_maintenance end def scheduled_maintenance(start_time, end_time) # sched_maintenance is an array of hashes, with [duration, timestamp, summary] keys sched_maintenance = @entity_check.maintenances(start_time, end_time, @@ -109,21 +109,23 @@ start_in_sched = start_time.nil? ? [] : @entity_check.maintenances(nil, start_time, :scheduled => true).select {|ps| ps[:end_time] >= start_time } - {:scheduled_maintenances => (start_in_sched + sched_maintenance)} + start_in_sched + sched_maintenance end # TODO test whether the below overlapping logic is prone to off-by-one # errors; the numbers may line up more neatly if we consider outages to # start one second after the maintenance period ends. # # TODO test performance with larger data sets def downtime(start_time, end_time) - outs = outage(start_time, end_time)[:outages] + sched_maintenances = scheduled_maintenance(start_time, end_time) + outs = outage(start_time, end_time) + total_secs = {} percentages = {} outs.collect {|obj| obj[:state]}.uniq.each do |st| total_secs[st] = 0 @@ -134,11 +136,9 @@ # Initially we need to check for cases where a scheduled # maintenance period is fully covered by an outage period. # We then create two new outage periods to cover the time around # the scheduled maintenance period, and remove the original. - - sched_maintenances = scheduled_maintenance(start_time, end_time)[:scheduled_maintenances] sched_maintenances.each do |sm| split_outs = []