<commit_before>class BulkDataStatusSetter

  attr_reader :changed_split_times, :changed_efforts, :report

  def self.set_data_status(args)
    bulk_setter = new(args)
    bulk_setter.set_data_status
    bulk_setter.save_changes
    bulk_setter.report
  end

  def initialize(args)
    ArgsValidator.validate(params: args,
                           required: :efforts,
                           exclusive: [:efforts, :times_container],
                           class: self.class)
    @efforts = args[:efforts]
    @times_container = args[:times_container] || SegmentTimesContainer.new(calc_model: :stats)
    @changed_split_times = []
    @changed_efforts = []
  end

  def set_data_status
    efforts.each do |effort|
      setter = effort_setter(effort)
      setter.set_data_status
      changed_split_times.push(*setter.changed_split_times)
      changed_efforts.push(*setter.changed_efforts)
    end
  end

  def save_changes
    split_time_report = BulkUpdateService.update_attributes(:split_times, changed_split_time_attributes)
    effort_report = BulkUpdateService.update_attributes(:efforts, changed_effort_attributes)
    self.report = "#{split_time_report} #{effort_report}"
  end
<commit_msg>Increase flexibility of BulkDataStatusSetter by allowing a :calc_model parameter.<commit_after>class BulkDataStatusSetter

  attr_reader :changed_split_times, :changed_efforts, :report

  def self.set_data_status(args)
    bulk_setter = new(args)
    bulk_setter.set_data_status
    bulk_setter.save_changes
    bulk_setter.report
  end

  def initialize(args)
    ArgsValidator.validate(params: args,
                           required: :efforts,
                           exclusive: [:efforts, :calc_model, :times_container],
                           class: self.class)
    @efforts = args[:efforts]
    @times_container = args[:times_container] || SegmentTimesContainer.new(calc_model: args[:calc_model] || :stats)
    @changed_split_times = []
    @changed_efforts = []
  end

  def set_data_status
    efforts.each do |effort|
      setter = effort_setter(effort)
      setter.set_data_status
      changed_split_times.push(*setter.changed_split_times)
      changed_efforts.push(*setter.changed_efforts)
    end
  end

  def save_changes
    split_time_report = BulkUpdateService.update_attributes(:split_times, changed_split_time_attributes)
    effort_report = BulkUpdateService.update_attributes(:efforts, changed_effort_attributes)
    self.report = "#{split_time_report} #{effort_report}"
  end

{'fraction_non_alphanumeric': 0.08300238284352661, 'fraction_numerical': 0.0, 'mean_word_length': 3.5551537070524413, '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': '808471', 'n_tokens_mistral': 783, 'n_tokens_neox': 782, 'n_words': 126}