Cache bust banished users' posts after the posts are deleted (#3044)
* Bust article caches after they've been deleted * Use less instances of cachebuster class
This commit is contained in:
parent
40832602ce
commit
a55bce99ac
1 changed files with 8 additions and 3 deletions
|
|
@ -15,9 +15,10 @@ module Moderator
|
|||
def delete_comments
|
||||
return unless user.comments.any?
|
||||
|
||||
cachebuster = CacheBuster.new
|
||||
user.comments.find_each do |comment|
|
||||
comment.reactions.delete_all
|
||||
CacheBuster.new.bust_comment(comment.commentable, user.username)
|
||||
cachebuster.bust_comment(comment.commentable, user.username)
|
||||
comment.delete
|
||||
comment.remove_notifications
|
||||
end
|
||||
|
|
@ -26,17 +27,21 @@ module Moderator
|
|||
def delete_articles
|
||||
return unless user.articles.any?
|
||||
|
||||
cachebuster = CacheBuster.new
|
||||
virtual_articles = user.articles.map { |article| Article.new(article.attributes) }
|
||||
user.articles.find_each do |article|
|
||||
article.reactions.delete_all
|
||||
article.comments.includes(:user).find_each do |comment|
|
||||
comment.reactions.delete_all
|
||||
CacheBuster.new.bust_comment(comment.commentable, comment.user.username)
|
||||
cachebuster.bust_comment(comment.commentable, comment.user.username)
|
||||
comment.delete
|
||||
end
|
||||
CacheBuster.new.bust_article(article)
|
||||
article.remove_algolia_index
|
||||
article.delete
|
||||
end
|
||||
virtual_articles.each do |article|
|
||||
cachebuster.bust_article(article)
|
||||
end
|
||||
end
|
||||
|
||||
def delete_user_activity
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue