Skip to content

Commit

Permalink
Fixing dailyrain accums I hope
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Sep 24, 2020
1 parent e37af8f commit b76e005
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/lita/handlers/forecasts.rb
Expand Up @@ -36,6 +36,16 @@ def get_max_by_data_key(forecast, key, datum)
end
end

def get_sum_by_data_key(forecast, key, datum)
unless forecast[key].nil?
data_points = []
forecast[key]['data'].each do |data_point|
data_points.push data_point[datum]
end
data_points.sum
end
end

def get_avg_by_data_key(forecast, key, datum)
unless forecast[key].nil?
data_points = []
Expand Down Expand Up @@ -450,7 +460,7 @@ def do_the_daily_rain_thing(forecast)
end

max = get_max_by_data_key(forecast, 'hourly', 'precipProbability')
agg = get_aggregate_by_data_key(forecast, 'hourly', 'precipIntensity')
agg = get_sum_by_data_key(forecast, 'hourly', 'precipIntensity')

"48 hr #{precip_type}s |#{str}| max #{(max.to_f * 100).round}%, #{get_accumulation agg} accumulation"
end
Expand Down

0 comments on commit b76e005

Please sign in to comment.