<commit_before>require 'peoplefinder'

class Peoplefinder::Person < ActiveRecord::Base
  self.table_name = 'people'

  extend FriendlyId
  include Peoplefinder::Concerns::Searchable
  include Peoplefinder::Concerns::Completion
  include Peoplefinder::Concerns::Notifications
  include Peoplefinder::Concerns::WorkDays

  has_paper_trail ignore: [:updated_at, :created_at, :id, :slug,
                           :login_count, :last_login_at]
  mount_uploader :image, Peoplefinder::ImageUploader

  attr_accessor :crop_x, :crop_y, :crop_w, :crop_h, :role_names

  validates :surname, presence: true
  validates :email, presence: true, uniqueness: true

  has_many :memberships,
    -> { includes(:group).order('groups.name')  },
    dependent: :destroy
  has_many :groups, through: :memberships
  belongs_to :community

  accepts_nested_attributes_for :memberships,
    allow_destroy: true,
    reject_if: proc { |membership| membership['group_id'].blank? }

  default_scope { order(surname: :asc, given_name: :asc) }

  friendly_id :slug_source, use: :slugged

  before_save :sanitize_tags

  def self.namesakes(person)
    where(surname: person.surname).
    where(given_name: person.given_name).
    where.not(id: person.id)<commit_msg>Clean whitespaces from name and email on Person model<commit_after>require 'peoplefinder'

class Peoplefinder::Person < ActiveRecord::Base
  self.table_name = 'people'

  extend FriendlyId
  include Peoplefinder::Concerns::Searchable
  include Peoplefinder::Concerns::Completion
  include Peoplefinder::Concerns::Notifications
  include Peoplefinder::Concerns::WorkDays
  include Peoplefinder::Concerns::Sanitisable

  has_paper_trail ignore: [:updated_at, :created_at, :id, :slug,
                           :login_count, :last_login_at]
  mount_uploader :image, Peoplefinder::ImageUploader

  attr_accessor :crop_x, :crop_y, :crop_w, :crop_h, :role_names

  validates :surname, presence: true
  validates :email, presence: true, uniqueness: true

  sanitise_fields :given_name, :surname, :email

  has_many :memberships,
    -> { includes(:group).order('groups.name')  },
    dependent: :destroy
  has_many :groups, through: :memberships
  belongs_to :community

  accepts_nested_attributes_for :memberships,
    allow_destroy: true,
    reject_if: proc { |membership| membership['group_id'].blank? }

  default_scope { order(surname: :asc, given_name: :asc) }

  friendly_id :slug_source, use: :slugged

  before_save :sanitize_tags

  def self.namesakes(person)
    where(surname: person.surname).
    where(given_name: person.given_name).
    where.not(id: person.id)
{'fraction_non_alphanumeric': 0.10693752395553852, 'fraction_numerical': 0.0, 'mean_word_length': 5.013824884792626, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6938792', 'n_tokens_mistral': 883, 'n_tokens_neox': 837, 'n_words': 177}