<commit_before>class Mentor < User
  # Filters mentors by their kids coach. Used only in the mentor index form.
  attr_accessor :filter_by_coach_id
  # Filters mentors by their kids meeting day. Used only in the mentor index form.
  attr_accessor :filter_by_meeting_day

  has_many :kids
  has_many :admins, through: :kids
  has_many :secondary_kids, class_name: 'Kid',
                            foreign_key: 'secondary_mentor_id'
  has_many :journals
  has_many :reminders
  has_many :secondary_reminders, class_name: 'Reminder',
                                 foreign_key: 'secondary_mentor_id'
  has_many :schedules, as: :person
  belongs_to :primary_kids_school, class_name: 'School'

  accepts_nested_attributes_for :schedules

  after_save :release_relations, if: :inactive?

  def self.mentors_grouped_by_assigned_kids
    groups = { both: [], only_primary: [], only_secondary: [],
               none: [], substitute: [] }
    Mentor.active.each do |m|
      if m.substitute?
        groups[:substitute] << m
        next
      end
      case [m.kids.present?, m.secondary_kids.present?]
      when [true, true] then groups[:both] << m
      when [true, false] then groups[:only_primary] << m
      when [false, true] then groups[:only_secondary] << m
      when [false, false] then groups[:none] << m
      end
    end
    groups
  end

  # def human_primary_kids_meeting_day
  #   return nil if primary_kids_meeting_day.nil?
  #   I18n.t('date.day_names')[primary_kids_meeting_day]
  # end

  def total_duration
    journals.sum(:duration)
  end

  def month_count
    Journal.unscoped.where(mentor_id: id).select('DISTINCT (month, year)').count
  end

  def human_exit_kind
    return '' if exit_kind.blank?
    I18n.t(exit_kind, scope: 'exit_kind')
  end

  # shows when last schedule relation entry was edited
  def schedules_updated_at
    Schedule.schedules_updated_at(self)
  end

  protected

  # inactive mentors should not be connected to other persons
  def release_relations
    kids.clear
    secondary_kids.clear
  end
end<commit_msg>filter mentors on meeting day without primary kids meeting day field<commit_after>class Mentor < User
  # Filters mentors by their kids coach. Used only in the mentor index form.
  attr_accessor :filter_by_coach_id
  # Filters mentors by their kids meeting day. Used only in the mentor index form.
  attr_accessor :filter_by_meeting_day

  has_many :kids
  has_many :admins, through: :kids
  has_many :secondary_kids, class_name: 'Kid',
                            foreign_key: 'secondary_mentor_id'
  has_many :journals
  has_many :reminders
  has_many :secondary_reminders, class_name: 'Reminder',
                                 foreign_key: 'secondary_mentor_id'
  has_many :schedules, as: :person
  belongs_to :primary_kids_school, class_name: 'School'

  accepts_nested_attributes_for :schedules

  after_save :release_relations, if: :inactive?

  def self.mentors_grouped_by_assigned_kids
    groups = { both: [], only_primary: [], only_secondary: [],
               none: [], substitute: [] }
    Mentor.active.each do |m|
      if m.substitute?
        groups[:substitute] << m
        next
      end
      case [m.kids.present?, m.secondary_kids.present?]
      when [true, true] then groups[:both] << m
      when [true, false] then groups[:only_primary] << m
      when [false, true] then groups[:only_secondary] << m
      when [false, false] then groups[:none] << m
      end
    end
    groups
  end

  def total_duration
    journals.sum(:duration)
  end

  def month_count
    Journal.unscoped.where(mentor_id: id).select('DISTINCT (month, year)').count
  end

  def human_exit_kind
    return '' if exit_kind.blank?
    I18n.t(exit_kind, scope: 'exit_kind')
  end

  # shows when last schedule relation entry was edited
  def schedules_updated_at
    Schedule.schedules_updated_at(self)
  end

  protected

  # inactive mentors should not be connected to other persons
  def release_relations
    kids.clear
    secondary_kids.clear
  end
end
{'fraction_non_alphanumeric': 0.08453505718547986, 'fraction_numerical': 0.0014917951268025858, 'mean_word_length': 3.212565445026178, 'pattern_counts': {'":': 0, '<': 25, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5790223', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1263, 'n_words': 349}