Class: Renalware::HD::GenerateMonthlyStatistics

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/renalware/hd/generate_monthly_statistics.rb

Overview

TODO: not sure this needs to be a job - doesn’t seem to be used as such instead is invoked directly

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(month: nil, year: nil) ⇒ GenerateMonthlyStatistics

Returns a new instance of GenerateMonthlyStatistics.



16
17
18
19
20
21
22
23
# File 'app/jobs/renalware/hd/generate_monthly_statistics.rb', line 16

def initialize(month: nil, year: nil)
  validate_args(month: month, year: year)

  @period = Renalware::MonthPeriod.new(
    month: (month || default_month).to_i,
    year: (year || default_year).to_i
  )
end

Instance Attribute Details

#periodObject (readonly)

Returns the value of attribute period.



14
15
16
# File 'app/jobs/renalware/hd/generate_monthly_statistics.rb', line 14

def period
  @period
end

Instance Method Details

#callObject

:reek:UtilityFunction



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/jobs/renalware/hd/generate_monthly_statistics.rb', line 26

def call
  patients_with_a_closed_hd_session_in_period.each do |patient|
    GenerateMonthlyStatisticsForPatientJob.perform_later(
      patient: patient,
      month: period.month,
      year: period.year
    )
  end

  Rails.logger.info(
    "Enqueued GenerateMonthlyStatisticsForPatientJob jobs for "\
    "#{patients_with_a_closed_hd_session_in_period.length} patients"
  )
end