delegate removal from favorites and updating of user fav counts to delayed job
This commit is contained in:
@@ -815,19 +815,19 @@ class Post < ApplicationRecord
|
||||
|
||||
when /^-favgroup:(\d+)$/i
|
||||
favgroup = FavoriteGroup.where("id = ?", $1.to_i).for_creator(CurrentUser.user.id).first
|
||||
favgroup.remove!(self) if favgroup
|
||||
favgroup.remove!(id) if favgroup
|
||||
|
||||
when /^-favgroup:(.+)$/i
|
||||
favgroup = FavoriteGroup.named($1).for_creator(CurrentUser.user.id).first
|
||||
favgroup.remove!(self) if favgroup
|
||||
favgroup.remove!(id) if favgroup
|
||||
|
||||
when /^favgroup:(\d+)$/i
|
||||
favgroup = FavoriteGroup.where("id = ?", $1.to_i).for_creator(CurrentUser.user.id).first
|
||||
favgroup.add!(self) if favgroup
|
||||
favgroup.add!(id) if favgroup
|
||||
|
||||
when /^favgroup:(.+)$/i
|
||||
favgroup = FavoriteGroup.named($1).for_creator(CurrentUser.user.id).first
|
||||
favgroup.add!(self) if favgroup
|
||||
favgroup.add!(id) if favgroup
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1038,15 +1038,12 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def remove_from_favorites
|
||||
favorites.find_each do |fav|
|
||||
remove_favorite!(fav.user)
|
||||
end
|
||||
Favorite.delay.purge_post(id, fav_string.scan(/\d+/))
|
||||
PostVote.where(post_id: id).delete_all
|
||||
end
|
||||
|
||||
def remove_from_fav_groups
|
||||
FavoriteGroup.for_post(id).find_each do |group|
|
||||
group.remove!(self)
|
||||
end
|
||||
FavoriteGroup.delay.purge_post(id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1382,7 +1379,6 @@ class Post < ApplicationRecord
|
||||
transaction do
|
||||
Post.without_timeout do
|
||||
ModAction.log("permanently deleted post ##{id}")
|
||||
#delete!("Permanently deleted post ##{id}", :without_mod_action => true)
|
||||
|
||||
give_favorites_to_parent
|
||||
update_children_on_destroy
|
||||
|
||||
Reference in New Issue
Block a user