<commit_before>module SmartAnswer
  class AmIGettingMinimumWageFlow < Flow
    def define
      content_id "111e006d-2b22-4b1f-989a-56bb61355d68"
      name 'am-i-getting-minimum-wage'
      status :published
      satisfies_need "100145"

      # Q1
      multiple_choice :what_would_you_like_to_check? do
        option "current_payment"
        option "past_payment"

        calculate :calculator do |response|
          Calculators::MinimumWageCalculator.new(what_to_check: response)
        end

        calculate :accommodation_charge do
          nil
        end

        next_node do |response|
          case response
          when 'current_payment'
            question :are_you_an_apprentice?
          when 'past_payment'
            question :past_payment_date?
          end
        end
      end

      # Q3
      value_question :how_old_are_you?, parse: Integer do
        precalculate :age_title do
          if calculator.what_to_check == 'current_payment_april_2016'
            "How old will you be on 1 April 2016?"
          else
            "How old are you?"
          end
        end

        validate do |response|
          calculator.valid_age?(response)
        end

        validate :valid_age_for_living_wage? do |response|
          if calculator.what_to_check == 'current_payment_april_2016'
            calculator.valid_age_for_living_wage?(response)
          else
            true
          end
        end

        next_node do |response|
          calculator.age = response
          if calculator.under_school_leaving_age?
            outcome :under_school_leaving_age
          else
            question :how_often_do_you_get_paid?
          end
        end
      end

      use_shared_logic "minimum_wage"<commit_msg>Simplify age title precalculation<commit_after>module SmartAnswer
  class AmIGettingMinimumWageFlow < Flow
    def define
      content_id "111e006d-2b22-4b1f-989a-56bb61355d68"
      name 'am-i-getting-minimum-wage'
      status :published
      satisfies_need "100145"

      # Q1
      multiple_choice :what_would_you_like_to_check? do
        option "current_payment"
        option "past_payment"

        calculate :calculator do |response|
          Calculators::MinimumWageCalculator.new(what_to_check: response)
        end

        calculate :accommodation_charge do
          nil
        end

        next_node do |response|
          case response
          when 'current_payment'
            question :are_you_an_apprentice?
          when 'past_payment'
            question :past_payment_date?
          end
        end
      end

      # Q3
      value_question :how_old_are_you?, parse: Integer do
        precalculate :age_title do
          "How old are you?"
        end

        validate do |response|
          calculator.valid_age?(response)
        end

        validate :valid_age_for_living_wage? do |response|
          if calculator.what_to_check == 'current_payment_april_2016'
            calculator.valid_age_for_living_wage?(response)
          else
            true
          end
        end

        next_node do |response|
          calculator.age = response
          if calculator.under_school_leaving_age?
            outcome :under_school_leaving_age
          else
            question :how_often_do_you_get_paid?
          end
        end
      end

      use_shared_logic "minimum_wage"
{'fraction_non_alphanumeric': 0.0525383707201889, 'fraction_numerical': 0.023317591499409682, 'mean_word_length': 1.921551724137931, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2007773', 'n_tokens_mistral': 1070, 'n_tokens_neox': 977, 'n_words': 214}