fixes #2447: Display disapproval counts in status bar to uploader and approvers

This commit is contained in:
r888888888
2015-07-23 14:29:18 -07:00
parent 9f47a9da1b
commit 43377e3a82
4 changed files with 23 additions and 13 deletions

View File

@@ -1,4 +1,6 @@
class PostDisapproval < ActiveRecord::Base
DELETION_THRESHOLD = 1.month
belongs_to :post
belongs_to :user
validates_uniqueness_of :post_id, :scope => [:user_id], :message => "have already hidden this post"
@@ -10,7 +12,7 @@ class PostDisapproval < ActiveRecord::Base
scope :disinterest, lambda {where(:reason => ["disinterest", "legacy"])}
def self.prune!
joins(:post).where("posts.is_pending = FALSE AND posts.is_flagged = FALSE").each do |post_disapproval|
PostDisapproval.joins(:post).where("posts.is_pending = FALSE AND posts.is_flagged = FALSE and post_disapprovals.created_at < ?", DELETION_THRESHOLD.ago).each do |post_disapproval|
post_disapproval.destroy
end
end