<commit_before># Export Registrant and Event-Sign-Up information
class Exporters::RegistrantExporter
  def headers
    [
      "ID",
      "<NAME>",
      "<NAME>",
      "Birthday (dd/mm/yy)",
      "Sex (m/f)"
    ] + event_headers
  end

  def rows
    Registrant.all.includes(:registrant_best_times, :registrant_choices, registrant_event_sign_ups: [event_category: [:translations]]).map do |registrant|
      [
        registrant.bib_number.to_s,
        registrant.first_name,
        registrant.last_name,
        registrant.birthday.strftime("%d/%m/%y"),
        registrant.gender == "Male" ? "m" : "f"
      ] + event_rows(registrant)
    end
  end

  private

  def events
    @events ||= Event.all.order(:id).includes(:translations, event_choices: [:translations], event_categories: [:translations])
  end

  def event_headers
    result = []
    events.map do |event|
      result << "EV: #{event.name} - Signed Up (Y/N)"
      result << "EV: #{event.name} - Best Time (none)"

      category_names = event.event_categories.map(&:name).join("/")
      result << "EV: #{event.name} - Category (#{category_names})"

      event.event_choices.each do |event_choice|
        result << "EV: #{event.name} - Choice: #{event_choice.label}"
      end
    end

    result
  end

  def event_rows(registrant)
    result = []

    events.map do |event|
      resu = registrant.registrant_event_sign_ups.find{ |resup| resup.event_id == event.id }
      if resu&.signed_up?
        result << "Y"

        rbt = registrant.registrant_best_times.find{|rbtime| rbtime.event_id == event.id }
        if rbt
          result << rbt.formatted_value
        else
          result << ""
        end

        result << resu.event_category.name
        event.event_choices.each do |event_choice|
          rc = registrant.registrant_choices.find{|rchoice| rchoice.event_choice_id == event_choice.id }<commit_msg>export best time format in header properly<commit_after># Export Registrant and Event-Sign-Up information
class Exporters::RegistrantExporter
  def headers
    [
      "ID",
      "First Name",
      "<NAME>",
      "Birthday (dd/mm/yy)",
      "Sex (m/f)"
    ] + event_headers
  end

  def rows
    Registrant.all.includes(:registrant_best_times, :registrant_choices, registrant_event_sign_ups: [event_category: [:translations]]).map do |registrant|
      [
        registrant.bib_number.to_s,
        registrant.first_name,
        registrant.last_name,
        registrant.birthday.strftime("%d/%m/%y"),
        registrant.gender == "Male" ? "m" : "f"
      ] + event_rows(registrant)
    end
  end

  private

  def events
    @events ||= Event.all.order(:id).includes(:translations, event_choices: [:translations], event_categories: [:translations])
  end

  def event_headers
    result = []
    events.map do |event|
      result << "EV: #{event.name} - Signed Up (Y/N)"
      result << "EV: #{event.name} - Best Time (#{event.best_time_format})"

      category_names = event.event_categories.map(&:name).join("/")
      result << "EV: #{event.name} - Category (#{category_names})"

      event.event_choices.each do |event_choice|
        result << "EV: #{event.name} - Choice: #{event_choice.label}"
      end
    end

    result
  end

  def event_rows(registrant)
    result = []

    events.map do |event|
      resu = registrant.registrant_event_sign_ups.find{ |resup| resup.event_id == event.id }
      if resu&.signed_up?
        result << "Y"

        rbt = registrant.registrant_best_times.find{|rbtime| rbtime.event_id == event.id }
        if rbt
          result << rbt.formatted_value
        else
          result << ""
        end

        result << resu.event_category.name
        event.event_choices.each do |event_choice|
          rc = registrant.registrant_choices.find{|rchoice| rchoice.event_choice_id == event_choice.id }
{'fraction_non_alphanumeric': 0.131811105345096, 'fraction_numerical': 0.0, 'mean_word_length': 2.7318489835430784, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 6, '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': '1877092', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1278, 'n_words': 249}