consolidate update_column calls on posts

This commit is contained in:
r888888888
2016-08-12 13:34:02 -07:00
parent 6ff78c29e7
commit 1974db27b6

View File

@@ -1022,11 +1022,13 @@ class Post < ActiveRecord::Base
module CountMethods module CountMethods
def fix_post_counts def fix_post_counts
post.set_tag_counts post.set_tag_counts
post.update_column(:tag_count, post.tag_count) post.update_columns(
post.update_column(:tag_count_general, post.tag_count_general) :tag_count => post.tag_count,
post.update_column(:tag_count_artist, post.tag_count_artist) :tag_count_general => post.tag_count_general,
post.update_column(:tag_count_copyright, post.tag_count_copyright) :tag_count_artist => post.tag_count_artist,
post.update_column(:tag_count_character, post.tag_count_character) :tag_count_copyright => post.tag_count_copyright,
:tag_count_character => post.tag_count_character
)
end end
def get_count_from_cache(tags) def get_count_from_cache(tags)
@@ -1292,10 +1294,16 @@ class Post < ActiveRecord::Base
end end
Post.transaction do Post.transaction do
update_column(:is_deleted, true) self.is_deleted = true
update_column(:is_pending, false) self.is_pending = false
update_column(:is_flagged, false) self.is_flagged = false
update_column(:is_banned, true) if options[:ban] || has_tag?("banned_artist") self.is_banned = true if options[:ban] || has_tag?("banned_artist")
update_columns(
:is_deleted => is_deleted,
:is_pending => is_pending,
:is_flagged => is_flagged,
:is_banned => is_banned
)
give_favorites_to_parent if options[:move_favorites] give_favorites_to_parent if options[:move_favorites]
update_parent_on_save update_parent_on_save