<commit_before># frozen_string_literal: true

class EffortAuditView < EffortWithLapSplitRows

  DISCREPANCY_THRESHOLD = 1.minute

  delegate :event_name, :person, :start_time, :has_start_time?, :stopped?, to: :loaded_effort
  delegate :simple?, :multiple_sub_splits?, :multiple_laps?, :laps_unlimited?, :event_group, to: :event

  def audit_rows
    name_method = multiple_laps? ? :name : :name_without_lap

    lap_splits.flat_map do |lap_split|
      lap_split.bitkeys.map do |bitkey|
        time_point = lap_split.time_point(bitkey)
        split_time = split_times.find { |st| st.time_point == time_point }
        matched_raw_times = raw_times.select { |rt| rt.split_time_id && rt.split_time_id == split_time&.id }
        unmatched_raw_times = raw_times.select { |rt| rt.split_time_id.nil? && rt.time_point == split_time.time_point }
        OpenStruct.new(name: lap_split.public_send(name_method, bitkey),
                       time_point: time_point,<commit_msg>Refine EffortAuditView<commit_after># frozen_string_literal: true

class EffortAuditView < EffortWithLapSplitRows

  DISCREPANCY_THRESHOLD = 1.minute

  delegate :event_name, :person, :start_time, :has_start_time?, :stopped?, to: :loaded_effort
  delegate :simple?, :multiple_sub_splits?, :multiple_laps?, :laps_unlimited?, :event_group, to: :event

  def audit_rows
    name_method = multiple_laps? ? :name : :name_without_lap

    lap_splits.flat_map do |lap_split|
      lap_split.bitkeys.map do |bitkey|
        time_point = lap_split.time_point(bitkey)
        split_time = indexed_split_times[time_point] || effort.split_times.new(time_point: time_point)
        matched_raw_times = raw_times.select { |rt| rt.split_time_id && rt.split_time_id == split_time.id }
        unmatched_raw_times = raw_times.select { |rt| rt.split_time_id.nil? && rt.time_point == time_point }

        OpenStruct.new(name: lap_split.public_send(name_method, bitkey),
                       time_point: time_point,
{'fraction_non_alphanumeric': 0.10406091370558376, 'fraction_numerical': 0.0010152284263959391, 'mean_word_length': 4.2841823056300266, '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': '956841', 'n_tokens_mistral': 694, 'n_tokens_neox': 679, 'n_words': 119}