* Added statistics-based estimator for related tag calculator * Fleshed out IpBan class based on changes to Danbooru 1.xx
22 lines
453 B
Ruby
22 lines
453 B
Ruby
class CommentVote < ActiveRecord::Base
|
|
class Error < Exception ; end
|
|
|
|
attr_accessor :is_positive
|
|
validates_uniqueness_of :ip_addr, :scope => :comment_id
|
|
belongs_to :comment
|
|
belongs_to :user
|
|
after_save :update_comment_score
|
|
|
|
def self.prune!
|
|
destroy_all(["created_at < ?", 14.days.ago])
|
|
end
|
|
|
|
def update_comment_score
|
|
if is_positive
|
|
comment.increment!(:score)
|
|
else
|
|
comment.decrement!(:score)
|
|
end
|
|
end
|
|
end
|