<commit_before>class User < ActiveRecord::Base
  include ActiveModel::ForbiddenAttributesProtection
  include Gravtastic

  attr_accessor :login
  
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable,
         :recoverable, :rememberable, :trackable, :validatable,
         :authentication_keys => [:login]

  has_many :questions
  has_many :answers
  has_many :votes
  has_gravatar :size => '80', :secure => false


  # Public: Determine whether this user has voted on a given object before.
  #
  # This method examines the collection of votes associated with this user,
  # returning true if the collection includes a vote on the object, and false if not.
  #
  # voteable - The voteable object (currently either question or answer) that should
  # be checked for in the votes collection
  # 
  # Returns true if the voteable exists in the collection of votes, and false if not
  def voted_on?(voteable)
    self.votes.where(:voteable => voteable)<commit_msg>Extend voted_on? method to optionally scope by direction<commit_after>class User < ActiveRecord::Base
  include ActiveModel::ForbiddenAttributesProtection
  include Gravtastic

  attr_accessor :login
  
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable,
         :recoverable, :rememberable, :trackable, :validatable,
         :authentication_keys => [:login]

  has_many :questions
  has_many :answers
  has_many :votes
  has_gravatar :size => '80', :secure => false


  # Public: Determine whether this user has voted on a given object before.
  #
  # This method examines the collection of votes associated with this user,
  # returning true if the collection includes a vote on the object, and false if not.
  #
  # voteable - The voteable object (currently either question or answer) that should
  # be checked for in the votes collection
  # direction - The direction to scope to, or either up or down if nil
  # 
  # Returns true if the voteable exists in the collection of votes, and false if not
  def voted_on?(voteable, direction = ['up', 'down'])
    !self.votes.where(:voteable_id => voteable.id, :voteable_type => voteable.class.name).where(direction.nil? ? '1=1' : {:direction => direction}).count.zero?
{'fraction_non_alphanumeric': 0.07991803278688525, 'fraction_numerical': 0.002459016393442623, 'mean_word_length': 4.215811965811966, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '463913', 'n_tokens_mistral': 710, 'n_tokens_neox': 674, 'n_words': 259}