Sha256: 744bff5bb228766738622a303db5024bc58ab62f6579424b8b39d79ecd4d279a

Contents?: true

Size: 1.28 KB

Versions: 10

Compression:

Stored size: 1.28 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
          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

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.0.89 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.88 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.87 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.86 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.85 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.84 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.83 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.82 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.81 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
renalware-core-2.0.80 app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb