<commit_before>module SmartAnswer
  class OverseasPassportsFlow < Flow
    def define
      content_id "dd113259-fcaf-4e9b-83d5-d1148f33cf34"
      name 'overseas-passports'
      status :published
      satisfies_need "100131"

      data_query = Calculators::PassportAndEmbassyDataQuery.new

      # Q1
      country_select :which_country_are_you_in?, exclude_countries: Calculators::OverseasPassportsCalculator::EXCLUDE_COUNTRIES do
        next_node_calculation :calculator do
          Calculators::OverseasPassportsCalculator.new
        end

        calculate :location do |response|
          loc = WorldLocation.find(response)
          if Calculators::PassportAndEmbassyDataQuery::ALT_EMBASSIES.has_key?(response)
            loc = WorldLocation.find(Calculators::PassportAndEmbassyDataQuery::ALT_EMBASSIES[response])
          end
          raise InvalidResponse unless loc
          loc
        end

        calculate :birth_location do
          nil
        end
        calculate :embassy_address do
          nil
        end
        calculate :send_colour_photocopy_bulletpoint do
          nil
        end

        next_node(permitted: :auto) do |response|<commit_msg>Optimise find world location in overseas passports<commit_after>module SmartAnswer
  class OverseasPassportsFlow < Flow
    def define
      content_id "dd113259-fcaf-4e9b-83d5-d1148f33cf34"
      name 'overseas-passports'
      status :published
      satisfies_need "100131"

      data_query = Calculators::PassportAndEmbassyDataQuery.new

      # Q1
      country_select :which_country_are_you_in?, exclude_countries: Calculators::OverseasPassportsCalculator::EXCLUDE_COUNTRIES do
        next_node_calculation :calculator do
          Calculators::OverseasPassportsCalculator.new
        end

        calculate :location do |response|
          search_location = Calculators::PassportAndEmbassyDataQuery::ALT_EMBASSIES[response] || response

          loc = WorldLocation.find(search_location)
          raise InvalidResponse unless loc
          loc
        end

        calculate :birth_location do
          nil
        end
        calculate :embassy_address do
          nil
        end
        calculate :send_colour_photocopy_bulletpoint do
          nil
        end

        next_node(permitted: :auto) do |response|
{'fraction_non_alphanumeric': 0.0540891389009087, 'fraction_numerical': 0.02250108178277802, 'mean_word_length': 2.6992, 'pattern_counts': {'":': 0, '<': 5, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6261532', 'n_tokens_mistral': 710, 'n_tokens_neox': 663, 'n_words': 131}