Sha256: 488e2cf4780ef950219e4aa4050e9ef0986840e98f135b2e2bc94855bc2e8c68

Contents?: true

Size: 1.3 KB

Versions: 28

Compression:

Stored size: 1.3 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();")
            true
          end
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
renalware-core-2.0.153 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.152 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.151 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.149 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.148 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.147 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.146 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.145 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.144 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.143 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.142 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.141 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.140 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.139 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.138 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.137 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.136 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.135 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.134 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.133 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb