Sha256: 432a18215ae50bcc0f839e63fa51884e81984cbbd9767e9ebe9ef322935ace55

Contents?: true

Size: 969 Bytes

Versions: 1

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
        3
      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

1 entries across 1 versions & 1 rubygems

Version Path
renalware-core-2.0.110 app/jobs/renalware/hd/update_rolling_patient_statistics_dj_job.rb