* Continued work on improving post view templates
* Added statistics-based estimator for related tag calculator * Fleshed out IpBan class based on changes to Danbooru 1.xx
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user