<commit_before>def panoptes_config
  return @config if @config
  key = "panoptes_#{ Rails.env }"
  config = YAML.load_file Rails.root.join('config/database.yml')
  raise "database.yml does not configure #{ key }\n\n" unless config
  @config = config[key]
end

namespace :panoptes do
  namespace :db do
    desc 'Setup postgres_fdw'
    task :setup_fdw => :environment do
      # Setup foreign data wrappers on Talk
      ActiveRecord::Base.connection.execute <<-SQL
        do language plpgsql $$
          begin
            if (select count(*) from pg_extension where extname = 'postgres_fdw') = 0 then
              create extension postgres_fdw;
            end if;
            
            if (select count(*) from pg_foreign_server where srvname = 'panoptes') = 0 then
              create server panoptes foreign data wrapper postgres_fdw options (
                host '#{ panoptes_config.fetch('host', 'localhost') }',
                dbname '#{ panoptes_config['database'] }',
                port '#{ panoptes_config.fetch('port', 5432) }'
              );<commit_msg>Foreign table host is localhost<commit_after>def panoptes_config
  return @config if @config
  key = "panoptes_#{ Rails.env }"
  config = YAML.load_file Rails.root.join('config/database.yml')
  raise "database.yml does not configure #{ key }\n\n" unless config
  @config = config[key]
end

namespace :panoptes do
  namespace :db do
    desc 'Setup postgres_fdw'
    task :setup_fdw => :environment do
      # Setup foreign data wrappers on Talk
      ActiveRecord::Base.connection.execute <<-SQL
        do language plpgsql $$
          begin
            if (select count(*) from pg_extension where extname = 'postgres_fdw') = 0 then
              create extension postgres_fdw;
            end if;
            
            if (select count(*) from pg_foreign_server where srvname = 'panoptes') = 0 then
              create server panoptes foreign data wrapper postgres_fdw options (
                host 'localhost',
                dbname '#{ panoptes_config['database'] }',
                port '#{ panoptes_config.fetch('port', 5432) }'
              );
{'fraction_non_alphanumeric': 0.09784644194756555, 'fraction_numerical': 0.0056179775280898875, 'mean_word_length': 2.40829346092504, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1021744', 'n_tokens_mistral': 634, 'n_tokens_neox': 606, 'n_words': 183}