<commit_before>require 'encoding'
require 'digest' # required for {set,reset}_api_token
require 'base64' # required for {set,reset}_api_token
# required for repository actions
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'repo', 'repository')

# We always assume the following fields exists:
# => :user_name, :last_name, :first_name
# If there are added columns, add the default values to default_values
class User < ActiveRecord::Base
  before_validation :strip_name

  # Group relationships
  has_many :memberships, dependent: :delete_all
  has_many :grade_entry_students
  has_many :groupings, through: :memberships
  has_many :notes, as: :noteable, dependent: :destroy
  has_many :accepted_memberships,
           -> { where membership_status: [StudentMembership::STATUSES[:accepted], StudentMembership::STATUSES[:inviter]] },
           class_name: 'Membership'
  has_many :annotations, as: :creator
  has_many :test_script_results, foreign_key: 'requested_by_id', dependent: :delete_all, inverse_of: :requested_by

  validates_presence_of     :user_name, :last_name, :first_name
  validates_uniqueness_of   :user_name
  validates_uniqueness_of   :email, :allow_nil => true
  validates_uniqueness_of   :id_number, :allow_nil => true

  validates_format_of       :type,          with: /Student|Admin|Ta|TestServer/
  # role constants<commit_msg>added splitpdflog as an association for user<commit_after>require 'encoding'
require 'digest' # required for {set,reset}_api_token
require 'base64' # required for {set,reset}_api_token
# required for repository actions
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'repo', 'repository')

# We always assume the following fields exists:
# => :user_name, :last_name, :first_name
# If there are added columns, add the default values to default_values
class User < ActiveRecord::Base
  before_validation :strip_name

  # Group relationships
  has_many :memberships, dependent: :delete_all
  has_many :grade_entry_students
  has_many :groupings, through: :memberships
  has_many :notes, as: :noteable, dependent: :destroy
  has_many :accepted_memberships,
           -> { where membership_status: [StudentMembership::STATUSES[:accepted], StudentMembership::STATUSES[:inviter]] },
           class_name: 'Membership'
  has_many :annotations, as: :creator
  has_many :test_script_results, foreign_key: 'requested_by_id', dependent: :delete_all, inverse_of: :requested_by
  has_many :split_pdf_logs

  validates_presence_of     :user_name, :last_name, :first_name
  validates_uniqueness_of   :user_name
  validates_uniqueness_of   :email, :allow_nil => true
  validates_uniqueness_of   :id_number, :allow_nil => true

  validates_format_of       :type,          with: /Student|Admin|Ta|TestServer/
  # role constants
{'fraction_non_alphanumeric': 0.10078909612625538, 'fraction_numerical': 0.0014347202295552368, 'mean_word_length': 5.441108545034642, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1258146', 'n_tokens_mistral': 885, 'n_tokens_neox': 862, 'n_words': 217}