<commit_before>module DateParamProcessor
  extend ActiveSupport::Concern

  included do
    rescue_from ActiveRecord::MultiparameterAssignmentErrors do
      process_date_params
      send(params[:action])
    end
  end

  module ClassMethods
    attr_reader :date_fields

    def date_field_params(*fields)
      @date_fields = fields
    end
  end

  private

  def process_date_params
    self.class.date_fields.each do |field|
      month = month(field)
      parsed_month = parse_month(month)
      params[object_name]["#{field}(2i)"] = parsed_month
    end
  end

  def day(field)
    params[object_name]["#{field}(3i)"]
  end

  def month(field)
    params[object_name]["#{field}(2i)"]
  end

  def year(field)
    params[object_name]["#{field}(3i)"]
  end
<commit_msg>Refactor date params processor<commit_after>module DateParamProcessor
  extend ActiveSupport::Concern

  included do
    rescue_from ActiveRecord::MultiparameterAssignmentErrors do
      process_date_params
      send(params[:action])
    end
  end

  private

  def process_date_params
    parse_months(params[object_name])
  end

  def parse_months(params)
    params.each do |key, value|
      parse_months(params[key]) if value.is_a?(Hash)
      params[key] = parse_month(value) if key =~ /\(2i\)/
    end
  end

{'fraction_non_alphanumeric': 0.09520123839009288, 'fraction_numerical': 0.003869969040247678, 'mean_word_length': 3.6510791366906474, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7051876', 'n_tokens_mistral': 428, 'n_tokens_neox': 419, 'n_words': 86}