Class: LoadAverageDaysForClaimCompletionJob
- Inherits:
-
Object
- Object
- LoadAverageDaysForClaimCompletionJob
- Includes:
- Sidekiq::Job
- Defined in:
- app/sidekiq/load_average_days_for_claim_completion_job.rb
Constant Summary collapse
- AVERAGE_DAYS_REGEX =
/([0-9]{1,3}(\.[0-9]{1,2})) days/
Instance Method Summary collapse
-
#connection ⇒ Object
this will go away once the file publishing is setup.
- #load_average_days ⇒ Object
- #perform ⇒ Object
Instance Method Details
#connection ⇒ Object
this will go away once the file publishing is setup.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/sidekiq/load_average_days_for_claim_completion_job.rb', line 7 def connection @conn ||= Faraday.new('https://www.va.gov/') do |faraday| faraday.use :breakers faraday.use Faraday::Response::RaiseError faraday.request :json faraday.response :json, content_type: /\bjson/ faraday.adapter Faraday.default_adapter end end |
#load_average_days ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/sidekiq/load_average_days_for_claim_completion_job.rb', line 21 def load_average_days rtn = connection.get('/disability/after-you-file-claim/').body matches = AVERAGE_DAYS_REGEX.match(rtn) if matches.present? && matches.length >= 1 rec = AverageDaysForClaimCompletion.new rec.average_days = matches[1].to_f rec.save! else logger.error('Unable to load average days, possibly the page has changed and the regex no longer matches!') end rescue Faraday::ClientError => e logger.error("Unable to load average days: #{e.}") end |
#perform ⇒ Object
35 36 37 38 39 |
# File 'app/sidekiq/load_average_days_for_claim_completion_job.rb', line 35 def perform logger.info('Beginning: LoadAverageDaysForClaimCompletionJob') load_average_days logger.info('Completing: LoadAverageDaysForClaimCompletionJob') end |