<commit_before>class User < ActiveRecord::Base

  has_one :user_profile

  has_many :user_wingsuits, :dependent => :destroy
  has_many :wingsuits, :through => :user_wingsuits

  has_many :tracks, :dependent => :destroy

  has_many :competitors
  has_many :events, :through => :competitors

  has_many :participation_forms
  has_many :invitations

  has_many :assignments
  has_many :roles, :through => :assignments

  before_save :build_profile, :assign_default_role

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :confirmable,
         :recoverable, :rememberable, :trackable, :validatable


  def self.search_by_name query
    User.where('LOWER(name) LIKE LOWER(?)', "%#{query}%")
  end

  def name
    self.user_profile.name
  end

  def has_role?(role_sym)
    roles.any? { |r| r.name.underscore.to_sym == role_sym }
  end

  def pf_status(event)
    pf = ParticipationForm.where('event_id = ? AND user_id = ?', event.id, self.id)
    if pf.present?
      pf.first.status
    end
  end

  def event_admin?(event)
    Organizer.where('event_id = ? AND user_id = ?', event.id, self.id).present? || has_role?(:admin)
  end

  def completed_profile?
    [:first_name, :last_name,
      :jumps_total, :jumps_wingsuit,
      :jumps_last_year, :jumps_wingsuit_last_year,
      :jumps_last_3m, :jumps_wingsuit_last_3m, :phone_number,
      :height, :weight, :shirt_size].each do |x|
<commit_msg>Проверка заполнения поля Домашняя ДЗ<commit_after>class User < ActiveRecord::Base

  has_one :user_profile

  has_many :user_wingsuits, :dependent => :destroy
  has_many :wingsuits, :through => :user_wingsuits

  has_many :tracks, :dependent => :destroy

  has_many :competitors
  has_many :events, :through => :competitors

  has_many :participation_forms
  has_many :invitations

  has_many :assignments
  has_many :roles, :through => :assignments

  before_save :build_profile, :assign_default_role

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :confirmable,
         :recoverable, :rememberable, :trackable, :validatable


  def self.search_by_name query
    User.where('LOWER(name) LIKE LOWER(?)', "%#{query}%")
  end

  def name
    self.user_profile.name
  end

  def has_role?(role_sym)
    roles.any? { |r| r.name.underscore.to_sym == role_sym }
  end

  def pf_status(event)
    pf = ParticipationForm.where('event_id = ? AND user_id = ?', event.id, self.id)
    if pf.present?
      pf.first.status
    end
  end

  def event_admin?(event)
    Organizer.where('event_id = ? AND user_id = ?', event.id, self.id).present? || has_role?(:admin)
  end

  def completed_profile?
    [:first_name, :last_name, :homeDZ_name,
      :jumps_total, :jumps_wingsuit,
      :jumps_last_year, :jumps_wingsuit_last_year,
      :jumps_last_3m, :jumps_wingsuit_last_3m, :phone_number,
      :height, :weight, :shirt_size].each do |x|

{'fraction_non_alphanumeric': 0.11484502446982056, 'fraction_numerical': 0.0013050570962479609, 'mean_word_length': 4.2320819112627985, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3578756', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1086, 'n_words': 231}