<commit_before>class Team < ActiveRecord::Base
  include ProfilesHelper, ColorHelper, HasSeason

  delegate :sponsored?, :voluntary?, to: :kind

  KINDS = %w(sponsored voluntary)

  validates :name, uniqueness: true, allow_blank: true
  # validate :must_have_members
  validate :disallow_multiple_student_roles

  attr_accessor :checked

  has_one :project, dependent: :destroy
  has_many :applications, dependent: :nullify
  has_many :application_drafts, dependent: :nullify
  has_many :roles, dependent: :destroy
  has_many :members, class_name: 'User', through: :roles, source: :user
  Role::ROLES.each do |role|
    has_many role.pluralize.to_sym, -> { where(roles: { name: role }) }, class_name: 'User', through: :roles, source: :user
  end
  has_many :sources, dependent: :destroy
  has_many :activities, dependent: :destroy
  has_one :last_activity, -> { order('id DESC') }, class_name: 'Activity'
  has_many :comments
  belongs_to :event

  accepts_nested_attributes_for :roles, :sources, :project, allow_destroy: true

  before_create :set_number
  before_save :set_last_checked, if: :checked

  class << self
    def ordered(sort = {})
      order([sort[:order] || 'kind, name || projects', sort[:direction] || 'asc'].join(' '))
    end

    def visible
      where("invisible IS NOT TRUE OR kind IN (?)", KINDS)
    end
  end

  def application
    @application ||= applications.where(season_id: Season.current.id).first<commit_msg>Disambiguate kinds field<commit_after>class Team < ActiveRecord::Base
  include ProfilesHelper, ColorHelper, HasSeason

  delegate :sponsored?, :voluntary?, to: :kind

  KINDS = %w(sponsored voluntary)

  validates :name, uniqueness: true, allow_blank: true
  # validate :must_have_members
  validate :disallow_multiple_student_roles

  attr_accessor :checked

  has_one :project, dependent: :destroy
  has_many :applications, dependent: :nullify
  has_many :application_drafts, dependent: :nullify
  has_many :roles, dependent: :destroy
  has_many :members, class_name: 'User', through: :roles, source: :user
  Role::ROLES.each do |role|
    has_many role.pluralize.to_sym, -> { where(roles: { name: role }) }, class_name: 'User', through: :roles, source: :user
  end
  has_many :sources, dependent: :destroy
  has_many :activities, dependent: :destroy
  has_one :last_activity, -> { order('id DESC') }, class_name: 'Activity'
  has_many :comments
  belongs_to :event

  accepts_nested_attributes_for :roles, :sources, :project, allow_destroy: true

  before_create :set_number
  before_save :set_last_checked, if: :checked

  class << self
    def ordered(sort = {})
      order([sort[:order] || 'kind, name || projects', sort[:direction] || 'asc'].join(' '))
    end

    def visible
      where("teams.invisible IS NOT TRUE OR teams.kind IN (?)", KINDS)
    end
  end

  def application
    @application ||= applications.where(season_id: Season.current.id).first
{'fraction_non_alphanumeric': 0.11962873839807495, 'fraction_numerical': 0.0, 'mean_word_length': 4.785288270377734, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '6229041', 'n_tokens_mistral': 946, 'n_tokens_neox': 921, 'n_words': 249}