5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/sandy/providers/storm_center.rb', line 5
def recursive_fetch_areas report_areas, sub_select_func, parent=nil
if report_areas
arr = []
report_areas.each do |report_area|
begin
latitude, longitude = cached_coordinates_for(report_area['area_name'].downcase)
options = {
parent: parent,
total_customers: report_area.fetch("total_custs", 0).to_i,
estimated_recovery_time: report_area.fetch("etr", nil),
latitude: latitude,
longitude: longitude,
children: recursive_fetch_areas(sub_select_func.call(report_area), sub_select_func, report_area)
}
arr.push Sandy::Area.new(report_area.fetch("custs_out", 0).to_i, sanitize_name(report_area.fetch("area_name", nil)), options)
rescue
next
end
end
arr
else
[]
end
end
|