<commit_before>class Team < ActiveRecord::Base
  has_many :team_members, dependent: :destroy
  has_many :members, through: :team_members,
                     source: :user
  has_many :team_invitations, dependent: :destroy

  belongs_to :owner, class_name: 'User'

  validates :name,
            presence: true,
            length: { minimum: 5, maximum: 40 },
            uniqueness: true

  after_create :add_owner_to_members

  def to_s
    name
  end

  def request_to_join!(user)
    team_invitations.requests_to_join.where(user_id: user.id).first_or_create!
  end

  def invite_to_join!(user)
    team_invitations.invitations.where(user_id: user.id).first_or_create!
  end

  private

  def add_owner_to_members
    team_member = team_members.build
    team_member.user_id = owner_id
    team_member.save!
  end
end<commit_msg>Active team member when creating team<commit_after>class Team < ActiveRecord::Base
  has_many :team_members, dependent: :destroy
  has_many :members, through: :team_members,
                     source: :user
  has_many :team_invitations, dependent: :destroy

  belongs_to :owner, class_name: 'User'

  validates :name,
            presence: true,
            length: { minimum: 5, maximum: 40 },
            uniqueness: true

  after_create :add_owner_to_members

  def to_s
    name
  end

  def request_to_join!(user)
    team_invitations.requests_to_join.where(user_id: user.id).first_or_create!
  end

  def invite_to_join!(user)
    team_invitations.invitations.where(user_id: user.id).first_or_create!
  end

  private

  def add_owner_to_members
    team_member = team_members.build
    team_member.active = true
    team_member.user_id = owner_id
    team_member.save!
  end
end
{'fraction_non_alphanumeric': 0.07906976744186046, 'fraction_numerical': 0.0034883720930232558, 'mean_word_length': 3.3241206030150754, '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': '5539482', 'n_tokens_mistral': 579, 'n_tokens_neox': 560, 'n_words': 122}