Class: VRE::CreateCh31SubmissionsReportJob

Inherits:
Object
  • Object
show all
Includes:
SentryLogging, Sidekiq::Job
Defined in:
app/sidekiq/vre/create_ch31_submissions_report_job.rb

Constant Summary collapse

STATSD_KEY_PREFIX =
'worker.vre.create_ch31_submissions_report_job'
RETRY =

Sidekiq has built in exponential back-off functionality for retries retry for 2d 1h 47m 12s github.com/sidekiq/sidekiq/wiki/Error-Handling

16

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Instance Method Details

#build_range(report_date) ⇒ Object (private)



42
43
44
45
46
47
# File 'app/sidekiq/vre/create_ch31_submissions_report_job.rb', line 42

def build_range(report_date)
  zone = 'Eastern Time (US & Canada)'
  begin_time = ActiveSupport::TimeZone[zone].parse("#{report_date} 00:00:00")
  end_time = ActiveSupport::TimeZone[zone].parse("#{report_date} 23:59:59")
  begin_time..end_time
end

#get_claims_created_between(range) ⇒ Object (private)



49
50
51
52
53
# File 'app/sidekiq/vre/create_ch31_submissions_report_job.rb', line 49

def get_claims_created_between(range)
  SavedClaim::VeteranReadinessEmploymentClaim.where(
    created_at: range
  ).sort_by { |claim| claim.parsed_form['veteranInformation']['regionalOffice'] }
end

#perform(sidekiq_scheduler_args, run_date = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/sidekiq/vre/create_ch31_submissions_report_job.rb', line 25

def perform(sidekiq_scheduler_args, run_date = nil)
  date = if run_date
           run_date
         else
           epoch = sidekiq_scheduler_args['scheduled_at']
           Time.zone.at(epoch).yesterday.strftime('%Y-%m-%d')
         end

   = get_claims_created_between(build_range(date))
  Ch31SubmissionsReportMailer.build().deliver_now unless FeatureFlipper.staging_email?
rescue
  Rails.logger.warn('VRE::CreateCh31SubmissionsReportJob failed, retrying...')
  raise
end