Skip to content

Commit

Permalink
Add unauthenticated weather checking before pass via openweathermap.org
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonblaha committed Jan 27, 2014
1 parent 341dd5d commit 477faf4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/models/pass.rb
Expand Up @@ -8,7 +8,13 @@ class Pass < ActiveRecord::Base

def weather_permits
# TODO check for cloudiness at the location and return false if it's cloudy
true
begin
weather = HTTParty.get('http://api.openweathermap.org/data/2.5/find?lat='+self.user.lat.to_s+'&lon='+self.user.long.to_s)
cloudy_percent = 30
return weather['list'].first['clouds']['all'].to_i < cloudy_percent
rescue
return true
end
end

def sun_permits
Expand Down

0 comments on commit 477faf4

Please sign in to comment.