Sha256: 5ef1da2dee07d410f1135cfbd54ee732ed62e5b0ea2fe393447373b8551add42

Contents?: true

Size: 969 Bytes

Versions: 55

Compression:

Stored size: 969 Bytes

Contents

# frozen_string_literal: true

# When executed this job updates rolling statistics for a patient's
# last past 12 HD sessions.
# Because this job will be triggered again the next time an HD Sessions is
# created, it is not crucial to keep each event around - ie they have a short
# shelf-life. For this reason we only retry 3 times then delete failed jobs.
module Renalware
  module HD
    UpdateRollingPatientStatisticsDjJob = Struct.new(:patient_id) do
      def perform
        patient = Renalware::HD::Patient.find(patient_id)
        UpdateRollingPatientStatistics.new(patient: patient).call
      end

      def max_attempts
        2
      end

      def queue_name
        "hd_patient_statistics"
      end

      def priority
        4
      end

      def destroy_failed_jobs?
        true
      end

      # Retry at intervals of 1, 2, 3 hours
      def reschedule_at(current_time, attempts)
        current_time + attempts.hours
      end
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.1.0 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.167 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.166 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.165 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.164 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.163 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.162 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.161 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.160 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.159 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.158 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.157 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.156 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.155 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.153 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.152 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.151 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.149 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb
renalware-core-2.0.148 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb