* Attempt number 1 * Fix rack_attack specs * Fix users_searches_users spec * Fix display_users_search_spec * Fix comment typo * Remove search:destroy task from cypress * Remove port 9300 from gitpod * Stub response in attack_spec
25 lines
701 B
Ruby
25 lines
701 B
Ruby
module Users
|
|
module DeleteArticles
|
|
module_function
|
|
|
|
def call(user)
|
|
return if user.articles.blank?
|
|
|
|
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
|
|
EdgeCache::BustComment.call(comment.commentable)
|
|
EdgeCache::BustUser.call(comment.user)
|
|
comment.delete
|
|
end
|
|
article.delete
|
|
article.purge
|
|
end
|
|
virtual_articles.each do |article|
|
|
EdgeCache::BustArticle.call(article)
|
|
end
|
|
end
|
|
end
|
|
end
|