Sha256: 116d6c1fb0872f38a93ebc88f25fdc7ffc2e19c6802e49ca87b41f92af17ce31

Contents?: true

Size: 1.31 KB

Versions: 32

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module Renalware
  module UKRDC
    module TreatmentTimeline
      # If the host site has defined a SQL function called ukrdc_prepare_tables() in any schema in
      # the current SEARCH_PATH, then we call it here. It will (we hope) generate massaged copies of
      # tables needed to later generate e.g. UKRDC treatments - for example at KCH the hd_profiles
      # table is massaged to correct migration artefacts and issues prior to the generation of the
      # UKRDC Treatment Timeline. Elsewhere we detect the presence of these prepared
      # tables (eg ukrdc_prepared_hd_profiles) and use them as the underlying table behind, in this
      # example, Renalware::HD::Profile, by setting class.table_name = 'ukrdc_prepared_hd_profiles'.
      # If the site has not defined the ukrdc_prepare_tables SQL function then we exit gracefully.
      class PrepareTables
        def self.call
          Treatment.delete_all
          connection = ActiveRecord::Base.connection
          result = connection.execute(<<-SQL)
            select 1 where exists(select 1 from pg_proc where proname = 'ukrdc_prepare_tables');
          SQL
          if result.ntuples == 1
            connection.execute("select ukrdc_prepare_tables();")
            return true
          end
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
renalware-core-2.0.124 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.123 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.121 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.120 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.119 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.118 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.117 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.116 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.115 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.113 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.112 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.111 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.110 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.109 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.108 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.106 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.105 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.104 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.103 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.102 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb