<commit_before># == Schema Information
#
# Table name: companies
#
#  id           :integer          not null, primary key
#  name         :string(255)
#  created_at   :datetime
#  updated_at   :datetime
#  timezone     :string(255)
#  email_domain :string(255)
#  botname      :string(255)
#

class Company < ActiveRecord::Base
  has_many :questions, dependent: :destroy
  has_many :users, dependent: :destroy
  has_many :answers, through: :questions

  has_one :collect_answers_schedule,
          class_name: 'ScheduledTime',
          foreign_key: 'collect_answers_schedule_id',
          dependent: :destroy
  has_one :collect_questions_schedule,
          class_name: 'ScheduledTime',
          foreign_key: 'collect_questions_schedule_id',
          dependent: :destroy
  has_one :email_answers_schedule,
          class_name: 'ScheduledTime',
          foreign_key: 'email_answers_schedule_id',
          dependent: :destroy

  after_create :create_default_schedules

  private
    def create_default_schedules
      self.timezone = Time.zone.name if self.timezone.nil?
      self.create_collect_answers_schedule({
        frequency: 'Weekly',
        day: '3',
        time: Time.parse('2000-01-01 9am utc')
      })
      self.create_collect_questions_schedule({
        frequency: 'Weekly',
        day: '2',
        time: Time.parse('2000-01-01 9am utc')
      })
      self.create_email_answers_schedule({
        frequency: 'Weekly',
        day: '1',
        time: Time.parse('2000-01-01 9am utc')
      })<commit_msg>Fixed default schedule time error with day for week<commit_after># == Schema Information
#
# Table name: companies
#
#  id           :integer          not null, primary key
#  name         :string(255)
#  created_at   :datetime
#  updated_at   :datetime
#  timezone     :string(255)
#  email_domain :string(255)
#  botname      :string(255)
#

class Company < ActiveRecord::Base
  has_many :questions, dependent: :destroy
  has_many :users, dependent: :destroy
  has_many :answers, through: :questions

  has_one :collect_answers_schedule,
          class_name: 'ScheduledTime',
          foreign_key: 'collect_answers_schedule_id',
          dependent: :destroy
  has_one :collect_questions_schedule,
          class_name: 'ScheduledTime',
          foreign_key: 'collect_questions_schedule_id',
          dependent: :destroy
  has_one :email_answers_schedule,
          class_name: 'ScheduledTime',
          foreign_key: 'email_answers_schedule_id',
          dependent: :destroy

  after_create :create_default_schedules

  private
    def create_default_schedules
      self.timezone = Time.zone.name if self.timezone.nil?
      self.create_collect_answers_schedule({
        frequency: 'Weekly',
        day: 'Wednesday',
        time: Time.parse('2000-01-01 9am utc')
      })
      self.create_collect_questions_schedule({
        frequency: 'Weekly',
        day: 'Wednesday',
        time: Time.parse('2000-01-01 9am utc')
      })
      self.create_email_answers_schedule({
        frequency: 'Weekly',
        day: 'Monday',
        time: Time.parse('2000-01-01 9am utc')
      })
{'fraction_non_alphanumeric': 0.09984, 'fraction_numerical': 0.02592, 'mean_word_length': 2.7982989064398542, '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': '7351773', 'n_tokens_mistral': 1037, 'n_tokens_neox': 948, 'n_words': 206}