<commit_before>require 'sequelizer'

DB = Object.new.extend(Sequelizer).db unless defined?(DB)
if DB.database_type == :impala
  # Make sure to issue USE statement for every new connection
  ac = DB.pool.after_connect
  DB.pool.after_connect = proc do |conn, server, db|
    DB.send(:log_connection_execute, conn, "USE #{DB.opts[:database]}")
    ac.call(conn, server, db) if ac
  end

  # Remove existing connnections, so that the next query will use a new connection
  # that the USE statement has been executed on
  DB.disconnect
end

if %w(omopv4 omopv4_plus).include?(ENV['CONCEPTQL_DATA_MODEL']) && !DB.table_exists?(:source_to_concept_map)
  $stderr.puts <<END
The source_to_concept_map table doesn't exist in this database,
so it appears this doesn't include the necessary OMOP vocabulary
data. Please review the README for how to setup the test database
with the vocabulary, which needs to be done before running tests.
END
  exit 1
end

<commit_msg>Warn when running tests without LEXICON_URL set<commit_after>require 'sequelizer'

DB = Object.new.extend(Sequelizer).db unless defined?(DB)
if DB.database_type == :impala
  # Make sure to issue USE statement for every new connection
  ac = DB.pool.after_connect
  DB.pool.after_connect = proc do |conn, server, db|
    DB.send(:log_connection_execute, conn, "USE #{DB.opts[:database]}")
    ac.call(conn, server, db) if ac
  end

  # Remove existing connnections, so that the next query will use a new connection
  # that the USE statement has been executed on
  DB.disconnect
end

if %w(omopv4 omopv4_plus).include?(ENV['CONCEPTQL_DATA_MODEL']) && !DB.table_exists?(:source_to_concept_map)
  $stderr.puts <<END
The source_to_concept_map table doesn't exist in this database,
so it appears this doesn't include the necessary OMOP vocabulary
data. Please review the README for how to setup the test database
with the vocabulary, which needs to be done before running tests.
END
  exit 1
end

unless ENV["LEXICON_URL"]
  $stderr.puts <<END
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Looks like you're running tests without LEXICON_URL set.

I'ma let you finish, but just know that you're probably going
run into some failing tests because they require Lexicon.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

END
end

{'fraction_non_alphanumeric': 0.12998266897746968, 'fraction_numerical': 0.0025996533795493936, 'mean_word_length': 5.044502617801047, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '442184', 'n_tokens_mistral': 723, 'n_tokens_neox': 690, 'n_words': 262}