Sha256: b2cef1a4d0b9320c099fe3e9cd29a5e999095db7e034dc0520e20bacafd2c3fc
Contents?: true
Size: 1.29 KB
Versions: 39
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true require_dependency "renalware/ukrdc" require "attr_extras" require "benchmark" module Renalware module UKRDC module TreatmentTimeline # Re-generates the ukrdc_treatments table class GenerateTreatments def self.call new.call end def call elapsed_ms = Benchmark.ms do generate_treatments end log("\nCreated #{UKRDC::Treatment.count} UKRDC Treatments in #{elapsed_ms / 1000.0}s") end private def patient_scope Renalware::Patient .select(:id) .where("send_to_renalreg = true or send_to_rpv = true") end # rubocop:disable Rails/Output, Metrics/AbcSize def generate_treatments PrepareTables.call Rails.logger.info "#{patient_scope.count} patients" patient_scope.find_each.with_index do |patient, index| print "\n#{patient.id}: " GenerateTimeline.new(patient).call # Start gargbage collection periodically to prevent server ram issues. GC.start if (index % 50).zero? end end # rubocop:enable Rails/Output, Metrics/AbcSize def log(msg) Rails.logger.info(msg) end end end end end
Version data entries
39 entries across 39 versions & 1 rubygems