Class: VRE::CreateCh31SubmissionsReportJob
- Inherits:
-
Object
- Object
- VRE::CreateCh31SubmissionsReportJob
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 =
16
Instance Method Summary
collapse
#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
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
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
|
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
submitted_claims = get_claims_created_between(build_range(date))
Ch31SubmissionsReportMailer.build(submitted_claims).deliver_now unless FeatureFlipper.staging_email?
rescue
Rails.logger.warn('VRE::CreateCh31SubmissionsReportJob failed, retrying...')
raise
end
|