Pārlūkot izejas kodu

Merge pull request #370 from alias1/weatheragent-tweaks

Weatheragent - Make expected_update_period_in_days an option
Andrew Cantino 10 gadi atpakaļ
vecāks
revīzija
c2f7b8a041
1 mainītis faili ar 6 papildinājumiem un 3 dzēšanām
  1. 6 3
      app/models/agents/weather_agent.rb

+ 6 - 3
app/models/agents/weather_agent.rb

@@ -19,6 +19,8 @@ module Agents
       You must setup an [API key for Wunderground](http://www.wunderground.com/weather/api/) in order to use this Agent with Wunderground.
 
       You must setup an [API key for Forecast](https://developer.forecast.io/) in order to use this Agent with ForecastIO.
+
+      Set `expected_update_period_in_days` to the maximum amount of time that you'd expect to pass between Events being created by this Agent.
     MD
 
     event_description <<-MD
@@ -49,7 +51,7 @@ module Agents
     default_schedule "8pm"
 
     def working?
-      event_created_within?(2) && !recent_error_logs?
+      event_created_within?((options['expected_update_period_in_days'].presence || 2).to_i) && !recent_error_logs?
     end
 
     def key_setup?
@@ -61,7 +63,8 @@ module Agents
         'service' => 'wunderground',
         'api_key' => 'your-key',
         'location' => '94103',
-        'which_day' => '1'
+        'which_day' => '1',
+        'expected_update_period_in_days' => '2'
       }
     end
 
@@ -163,7 +166,7 @@ module Agents
               'ozone' => value.ozone.to_s
             }
             return day
-          end    
+          end
         end
       end
     end