<commit_before># frozen_string_literal: true

FactoryBot.define do
  factory :supervisor_report do
    pictures_saved { [true, false].sample }
    passenger_statement { FFaker::Lorem.paragraphs(5).join "\n" }
    faxed { [nil, Time.zone.now].sample }
    test_status { SupervisorReport::REASONS_FOR_TEST.sample }
    testing_facility { SupervisorReport::TESTING_FACILITIES.sample }
    testing_facility_notified_at { Time.zone.now - 6.minutes }
    employee_notified_of_test_at { Time.zone.now - 5.minutes }
    employee_departed_to_test_at { Time.zone.now - 4.minutes }
    employee_arrived_at_test_at { Time.zone.now - 3.minutes }
    test_started_at { Time.zone.now - 2.minutes }
    test_ended_at { Time.zone.now - 1.minute }
    employee_returned_at { Time.zone.now }

    before :create do |report|
      report.saved_pictures = rand 50 if report.pictures_saved?
      if rand(20).zero?
        report.amplifying_comments = FFaker::Lorem.paragraph
      end

      rand(3).times do
        create :witness, supervisor_report: report
      end
      if report.test_status.include?('Post-Accident: Threshold met (completed drug test)')
        field = %w[
          test_due_to_bodily_injury
          test_due_to_disabling_damage
          test_due_to_fatality
        ].sample
        report.send field + '=', true
      elsif report.test_status.include?('Reasonable Suspicion: Completed drug test')
        report.observation_made_at = Time.zone.now - 5.minutes
        reason = %w[appearance behavior speech odor].sample
        report.send "test_due_to_employee_#{reason}=", true
        report.send "employee_#{reason}=", FFaker::Lorem.sentence<commit_msg>Updated the test suite to use defined custom messages, because FactoryBot messes with the data and validations.<commit_after># frozen_string_literal: true

FactoryBot.define do
  factory :supervisor_report do
    pictures_saved { [true, false].sample }
    passenger_statement { FFaker::Lorem.paragraphs(5).join "\n" }
    faxed { [nil, Time.zone.now].sample }
    test_status 'Post Accident: Threshold met and discounted (no drug test)'
    reason_driver_discounted 'Post-Accident: Threshold met (completed drug test)'
    testing_facility { SupervisorReport::TESTING_FACILITIES.sample }
    testing_facility_notified_at { Time.zone.now - 6.minutes }
    employee_notified_of_test_at { Time.zone.now - 5.minutes }
    employee_departed_to_test_at { Time.zone.now - 4.minutes }
    employee_arrived_at_test_at { Time.zone.now - 3.minutes }
    test_started_at { Time.zone.now - 2.minutes }
    test_ended_at { Time.zone.now - 1.minute }
    employee_returned_at { Time.zone.now }

    before :create do |report|
      report.saved_pictures = rand 50 if report.pictures_saved?
      if rand(20).zero?
        report.amplifying_comments = FFaker::Lorem.paragraph
      end

      rand(3).times do
        create :witness, supervisor_report: report
      end
      if report.test_status.include?('Post-Accident: Threshold met (completed drug test)')
        field = %w[
          test_due_to_bodily_injury
          test_due_to_disabling_damage
          test_due_to_fatality
        ].sample
        report.send field + '=', true
      elsif report.test_status.include?('Reasonable Suspicion: Completed drug test')
        report.observation_made_at = Time.zone.now - 5.minutes
        reason = %w[appearance behavior speech odor].sample
        report.send "test_due_to_employee_#{reason}=", true
        report.send "employee_#{reason}=", FFaker::Lorem.sentence
{'fraction_non_alphanumeric': 0.0952650978168415, 'fraction_numerical': 0.007371703997731784, 'mean_word_length': 3.286755771567436, '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': '3294835', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1105, 'n_words': 226}