<commit_before>class LiveFileTransformer

  require 'csv'

  def initialize(event, file, split_id)
    @event = event
    @file = file
    @split = Split.find_by_id(split_id)
    @transformed_rows = []
    @file_rows = []
    create_rows_from_file
    transform_rows
  end

  def returned_rows
    transformed_rows
  end

  private

  attr_reader :event, :file, :split
  attr_accessor :file_rows, :transformed_rows

  def create_rows_from_file
    CSV.foreach(file.path, headers: true) do |row|
      file_row = row.to_hash
      file_row[:splitId] = split_id
      file_rows << file_row
    end
  end

  def transform_rows
    calcs = EventSegmentCalcs.new(event)
    ordered_split_array = event.ordered_splits.to_a
    file_rows.each do |file_row|
      effort_data_object = LiveEffortData.new(event, file_row, calcs, ordered_split_array)
      transformed_rows << effort_data_object.response_row
    end
  end

  def split_id
    split ? split.id : nil
  end

end<commit_msg>Added zeroize methods to make imported times uniform (written by <NAME>)<commit_after>class LiveFileTransformer

  require 'csv'

  def initialize(event, file, split_id)
    @event = event
    @file = file
    @split = Split.find_by_id(split_id)
    @transformed_rows = []
    @file_rows = []
    create_rows_from_file
    transform_rows
  end

  def returned_rows
    transformed_rows
  end

  private

  attr_reader :event, :file, :split
  attr_accessor :file_rows, :transformed_rows

  def create_rows_from_file
    CSV.foreach(file.path, headers: true) do |row|
      file_row = row.to_hash
      file_row.symbolize_keys!
      zeroize_times(file_row)
      file_row[:splitId] = split_id
      file_rows << file_row
    end
  end

  def transform_rows
    calcs = EventSegmentCalcs.new(event)
    ordered_split_array = event.ordered_splits.to_a
    file_rows.each do |file_row|
      effort_data_object = LiveEffortData.new(event, file_row, calcs, ordered_split_array)
      transformed_rows << effort_data_object.response_row
    end
  end

  def split_id
    split ? split.id : nil
  end

  def zeroize_times(file_row)
    file_row[:timeIn] = zeroize(file_row[:timeIn])
    file_row[:timeOut] = zeroize(file_row[:timeOut])
  end

  def zeroize(time_string)
    time_components = time_string.split(':')
    time_components << "00" if time_components.count == 2
    time_components[0] = "0" + time_components[0] if time_components[0].length == 1
    time_components.join(":")
  end

end
{'fraction_non_alphanumeric': 0.0846839546191248, 'fraction_numerical': 0.0032414910858995136, 'mean_word_length': 3.5386029411764706, 'pattern_counts': {'":': 1, '<': 14, '<?xml version=': 0, '>': 4, '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': '2540252', 'n_tokens_mistral': 864, 'n_tokens_neox': 838, 'n_words': 177}