mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
flagging work, we should be clearing from the mod menu if a topic or post is deleted
This commit is contained in:
@@ -26,6 +26,8 @@ class Post < ActiveRecord::Base
|
||||
rate_limit
|
||||
|
||||
acts_as_paranoid
|
||||
after_recover :update_flagged_posts_count
|
||||
after_destroy :update_flagged_posts_count
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :topic, counter_cache: :posts_count
|
||||
@@ -163,6 +165,10 @@ class Post < ActiveRecord::Base
|
||||
where("(post_number = 1) or (score >= ?)", SiteSetting.best_of_score_threshold)
|
||||
end
|
||||
|
||||
def update_flagged_posts_count
|
||||
PostAction.update_flagged_posts_count
|
||||
end
|
||||
|
||||
def filter_quotes(parent_post=nil)
|
||||
return cooked if parent_post.blank?
|
||||
|
||||
|
||||
@@ -13,7 +13,10 @@ class PostAction < ActiveRecord::Base
|
||||
rate_limit :post_action_rate_limiter
|
||||
|
||||
def self.update_flagged_posts_count
|
||||
val = exec_sql('select count(*) from posts where deleted_at is null and id in (select post_id from post_actions where post_action_type_id in (?) and deleted_at is null)', PostActionType.FlagTypes).values[0][0].to_i
|
||||
val = exec_sql('select count(*) from posts p
|
||||
join topics t on t.id = p.topic_id
|
||||
where p.deleted_at is null and t.deleted_at is null and p.id in
|
||||
(select post_id from post_actions where post_action_type_id in (?) and deleted_at is null)', PostActionType.FlagTypes).values[0][0].to_i
|
||||
$redis.set('posts_flagged_count', val)
|
||||
|
||||
admins = User.exec_sql("select id from users where admin = 't'").map{|r| r["id"].to_i}
|
||||
|
||||
@@ -11,7 +11,9 @@ class Topic < ActiveRecord::Base
|
||||
|
||||
versioned :if => :new_version_required?
|
||||
acts_as_paranoid
|
||||
|
||||
after_recover :update_flagged_posts_count
|
||||
after_destroy :update_flagged_posts_count
|
||||
|
||||
rate_limit :default_rate_limiter
|
||||
rate_limit :limit_topics_per_day
|
||||
rate_limit :limit_private_messages_per_day
|
||||
@@ -387,6 +389,10 @@ class Topic < ActiveRecord::Base
|
||||
topic
|
||||
end
|
||||
|
||||
def update_flagged_posts_count
|
||||
PostAction.update_flagged_posts_count
|
||||
end
|
||||
|
||||
|
||||
# Create the summary of the interesting posters in a topic. Cheats to avoid
|
||||
# many queries.
|
||||
|
||||
Reference in New Issue
Block a user