<commit_before># frozen_string_literal: true

if lottery.entrants.exists?
  ::CSV.generate do |csv|
    csv << ["Results for #{lottery.name}"]

    lottery.divisions.each do |division|
      csv << ["\n"]
      csv << [division.name]
      csv << ["Accepted"]

      division.winning_entrants.each.with_index(1) do |entrant, i|
        csv << [
          i,
          entrant.first_name,
          entrant.last_name,
          entrant.gender,
          entrant.city,
          entrant.state_name,
          entrant.country_name,
        ]
      end

      csv << ["Wait List"]
      division.wait_list_entrants.each.with_index(1) do |entrant, i|
        csv << [
          i,
          entrant.first_name,
          entrant.last_name,
          entrant.gender,
          entrant.city,
          entrant.state_name,
          entrant.country_name,
        ]
      end
    end
  end
else
  "No records to export."
end
<commit_msg>Order divisions by name for lottery results export<commit_after># frozen_string_literal: true

if lottery.entrants.exists?
  ::CSV.generate do |csv|
    csv << ["Results for #{lottery.name}"]

    lottery.divisions.ordered_by_name.each do |division|
      csv << ["\n"]
      csv << [division.name]
      csv << ["Accepted"]

      division.winning_entrants.each.with_index(1) do |entrant, i|
        csv << [
          i,
          entrant.first_name,
          entrant.last_name,
          entrant.gender,
          entrant.city,
          entrant.state_name,
          entrant.country_name,
        ]
      end

      csv << ["Wait List"]
      division.wait_list_entrants.each.with_index(1) do |entrant, i|
        csv << [
          i,
          entrant.first_name,
          entrant.last_name,
          entrant.gender,
          entrant.city,
          entrant.state_name,
          entrant.country_name,
        ]
      end
    end
  end
else
  "No records to export."
end

{'fraction_non_alphanumeric': 0.10948140387637506, 'fraction_numerical': 0.0020953378732320588, 'mean_word_length': 1.7883211678832116, 'pattern_counts': {'":': 0, '<': 31, '<?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': '2540274', 'n_tokens_mistral': 633, 'n_tokens_neox': 605, 'n_words': 123}