<commit_before>module SmartAnswer
  class CalculateAgriculturalHolidayEntitlementFlow < Flow
    def define
      content_id "8834bc7c-7ac7-4d45-8a57-1d5a5dcd70a0"
      name 'calculate-agricultural-holiday-entitlement'
      status :published
      satisfies_need "100143"

      multiple_choice :work_the_same_number_of_days_each_week? do
        option "same-number-of-days"
        option "different-number-of-days"

        on_response do
          self.calculator = Calculators::AgriculturalHolidayEntitlementCalculator.new
        end

        next_node do |response|
          case response
          when 'same-number-of-days'
            question :how_many_days_per_week?
          when 'different-number-of-days'
            question :what_date_does_holiday_start?
          end
        end
      end

      multiple_choice :how_many_days_per_week? do
        option "7-days"
        option "6-days"
        option "5-days"
        option "4-days"
        option "3-days"
        option "2-days"
        option "1-day"

        on_response do |response|
          # XXX: this is a bit nasty and takes advantage of the fact that
          # to_i only looks for the very first integer
          calculator.days_worked_per_week = response.to_i
        end

        next_node do
          question :worked_for_same_employer?
        end
      end

      date_question :what_date_does_holiday_start? do
        from { Date.civil(Date.today.year, 1, 1) }
        to { Date.civil(Date.today.year + 1, 12, 31) }

        on_response do |response|
          calculator.holiday_starts_on = response
        end

        next_node do
          question :how_many_total_days?
        end
      end

      multiple_choice :worked_for_same_employer? do
        option "same-employer"
        option "multiple-employers"

        calculate :holiday_entitlement_days do |response|
          if response == 'same-employer'
            # This is calculated as a flat number based on the days you work
            # per week
            if !calculator.days_worked_per_week.nil?
              calculator.holiday_days(calculator.days_worked_per_week)
            elsif !calculator.weeks_from_october_1.nil?
              calculator.holiday_days(total_days_worked.to_f / calculator.weeks_from_october_1.to_f).round(10)
            end
          end
        end

        next_node do |response|
          case response
          when 'same-employer'
            outcome :done
          when 'multiple-employers'
            question :how_many_weeks_at_current_employer?
          end
        end
      end

      value_question :how_many_total_days?, parse: Integer do
        precalculate :available_days do
          calculator.available_days
        end

        validate { |response| response <= available_days }

        calculate :total_days_worked do |response|
          response
        end

        next_node do
          question :worked_for_same_employer?
        end
      end

      value_question :how_many_weeks_at_current_employer?, parse: Integer do
        next_node do
          outcome :done_with_number_formatting
        end

        #Has to be less than a full year
        validate { |response| response < 52 }

        calculate :holiday_entitlement_days do |response|
          if !calculator.days_worked_per_week.nil?
            days = calculator.holiday_days(calculator.days_worked_per_week)
          elsif !calculator.weeks_from_october_1.nil?
            days = calculator.holiday_days(total_days_worked.to_f / calculator.weeks_from_october_1.to_f).round(10)
          end
          (days * (response / 52.0)).round(10)
        end
      end

      outcome :done
      outcome :done_with_number_formatting
    end
  end
end<commit_msg>Put blocks in last question in a more logical order<commit_after>module SmartAnswer
  class CalculateAgriculturalHolidayEntitlementFlow < Flow
    def define
      content_id "8834bc7c-7ac7-4d45-8a57-1d5a5dcd70a0"
      name 'calculate-agricultural-holiday-entitlement'
      status :published
      satisfies_need "100143"

      multiple_choice :work_the_same_number_of_days_each_week? do
        option "same-number-of-days"
        option "different-number-of-days"

        on_response do
          self.calculator = Calculators::AgriculturalHolidayEntitlementCalculator.new
        end

        next_node do |response|
          case response
          when 'same-number-of-days'
            question :how_many_days_per_week?
          when 'different-number-of-days'
            question :what_date_does_holiday_start?
          end
        end
      end

      multiple_choice :how_many_days_per_week? do
        option "7-days"
        option "6-days"
        option "5-days"
        option "4-days"
        option "3-days"
        option "2-days"
        option "1-day"

        on_response do |response|
          # XXX: this is a bit nasty and takes advantage of the fact that
          # to_i only looks for the very first integer
          calculator.days_worked_per_week = response.to_i
        end

        next_node do
          question :worked_for_same_employer?
        end
      end

      date_question :what_date_does_holiday_start? do
        from { Date.civil(Date.today.year, 1, 1) }
        to { Date.civil(Date.today.year + 1, 12, 31) }

        on_response do |response|
          calculator.holiday_starts_on = response
        end

        next_node do
          question :how_many_total_days?
        end
      end

      multiple_choice :worked_for_same_employer? do
        option "same-employer"
        option "multiple-employers"

        calculate :holiday_entitlement_days do |response|
          if response == 'same-employer'
            # This is calculated as a flat number based on the days you work
            # per week
            if !calculator.days_worked_per_week.nil?
              calculator.holiday_days(calculator.days_worked_per_week)
            elsif !calculator.weeks_from_october_1.nil?
              calculator.holiday_days(total_days_worked.to_f / calculator.weeks_from_october_1.to_f).round(10)
            end
          end
        end

        next_node do |response|
          case response
          when 'same-employer'
            outcome :done
          when 'multiple-employers'
            question :how_many_weeks_at_current_employer?
          end
        end
      end

      value_question :how_many_total_days?, parse: Integer do
        precalculate :available_days do
          calculator.available_days
        end

        validate { |response| response <= available_days }

        calculate :total_days_worked do |response|
          response
        end

        next_node do
          question :worked_for_same_employer?
        end
      end

      value_question :how_many_weeks_at_current_employer?, parse: Integer do
        #Has to be less than a full year
        validate { |response| response < 52 }

        calculate :holiday_entitlement_days do |response|
          if !calculator.days_worked_per_week.nil?
            days = calculator.holiday_days(calculator.days_worked_per_week)
          elsif !calculator.weeks_from_october_1.nil?
            days = calculator.holiday_days(total_days_worked.to_f / calculator.weeks_from_october_1.to_f).round(10)
          end
          (days * (response / 52.0)).round(10)
        end

        next_node do
          outcome :done_with_number_formatting
        end
      end

      outcome :done
      outcome :done_with_number_formatting
    end
  end
end
{'fraction_non_alphanumeric': 0.06066225165562914, 'fraction_numerical': 0.014304635761589404, 'mean_word_length': 2.064529220779221, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5396687', 'n_tokens_mistral': 2378, 'n_tokens_neox': 2211, 'n_words': 500}