<commit_before>class Country
  class << self
    def base_path
      "#{ENV['CARTO_API_URL']}/sql?q="
    end

    def find_all
      url = "#{base_path}SELECT iso, country as name FROM umd_nat_staging GROUP BY iso, name ORDER BY name"
      response = Typhoeus.get(url, headers: {"Accept" => "application/json"})
      if response.success?
        Rails.cache.fetch 'countries', expires_in: 1.day do
          JSON.parse(response.body)['countries']
        end
      else
        nil
      end
    end

    def find_by_iso_or_name(value)
      find_by_iso(value) || find_by_name(value)
    end

    def find_by_iso(iso)
      return nil unless iso<commit_msg>fix countries fetch in modal<commit_after>class Country
  class << self
    def base_path
      "#{ENV['CARTO_API_URL']}/sql?q="
    end

    def find_all
      url = "#{ENV['GFW_API_HOST']}/countries"
      response = Typhoeus.get(url, headers: {"Accept" => "application/json"})
      if response.success?
        JSON.parse(response.body)['countries']
      else
        nil
      end
    end

    def find_by_iso_or_name(value)
      find_by_iso(value) || find_by_name(value)
    end

    def find_by_iso(iso)
      return nil unless iso
{'fraction_non_alphanumeric': 0.10833333333333334, 'fraction_numerical': 0.0008333333333333334, 'mean_word_length': 2.639393939393939, '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': '5285363', 'n_tokens_mistral': 417, 'n_tokens_neox': 401, 'n_words': 92}