<commit_before>class CountriesGeometryImporter
  FILEPATH = Rails.root.join('tmp', 'countries_geometries_dump.tar.gz').to_s

  RESTORE_TEMPLATE = File.read(File.join(File.dirname(__FILE__), 'pg_restore_command.erb'))

  AREA_TYPES = ['LAND','TS','EEZ']
  COMPLEX_COUNTRIES = { 'TS' => ['CIV'],'LAND' => [],'EEZ' => []}

  def self.import
    importer = self.new
    importer.import
  end

  def initialize
    @s3 = AWS::S3.new({
      access_key_id: Rails.application.secrets.aws_access_key_id,
      secret_access_key: Rails.application.secrets.aws_secret_access_key
    })
  end

  def import
    download and restore_to_temporary_table and copy_countries and cleanup
  end

  private

  DB = ActiveRecord::Base.connection

  def download<commit_msg>Country geometry import ignores postgres errors<commit_after>class CountriesGeometryImporter
  FILEPATH = Rails.root.join('tmp', 'countries_geometries_dump.tar.gz').to_s

  RESTORE_TEMPLATE = File.read(File.join(File.dirname(__FILE__), 'pg_restore_command.erb'))

  AREA_TYPES = ['LAND','TS','EEZ']
  COMPLEX_COUNTRIES = { 'TS' => ['CIV'],'LAND' => [],'EEZ' => []}

  def self.import
    importer = self.new
    importer.import
  end

  def initialize
    @s3 = AWS::S3.new({
      access_key_id: Rails.application.secrets.aws_access_key_id,
      secret_access_key: Rails.application.secrets.aws_secret_access_key
    })
  end

  def import
    download
    restore_to_temporary_table
    copy_countries
  ensure
    cleanup
  end

  private

  DB = ActiveRecord::Base.connection

  def download
{'fraction_non_alphanumeric': 0.11878631375080698, 'fraction_numerical': 0.0025823111684958036, 'mean_word_length': 4.132450331125828, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1678768', 'n_tokens_mistral': 566, 'n_tokens_neox': 534, 'n_words': 90}