add post count estimates for bulk update requests
This commit is contained in:
@@ -78,6 +78,28 @@ class AliasAndImplicationImporter
|
||||
end
|
||||
end
|
||||
|
||||
def estimate_update_count
|
||||
tokens = self.class.tokenize(text)
|
||||
tokens.inject(0) do |sum, token|
|
||||
case token[0]
|
||||
when :create_alias
|
||||
sum + TagAlias.new(antecedent_name: token[1], consequent_name: token[2]).estimate_update_count
|
||||
|
||||
when :create_implication
|
||||
sum + TagImplication.new(antecedent_name: token[1], consequent_name: token[2]).estimate_update_count
|
||||
|
||||
when :mass_update
|
||||
sum + Moderator::TagBatchChange.new(token[1], token[2]).estimate_update_count
|
||||
|
||||
when :change_category
|
||||
sum + Tag.find_by_name(token[1]).try(:post_count) || 0
|
||||
|
||||
else
|
||||
sum + 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse(tokens, approver)
|
||||
|
||||
@@ -20,6 +20,10 @@ module Moderator
|
||||
ModAction.log("processed mass update: #{antecedent} -> #{consequent}",:mass_update)
|
||||
end
|
||||
|
||||
def estimate_update_count
|
||||
PostReadOnly.tag_match(antecedent).count
|
||||
end
|
||||
|
||||
def migrate_posts(normalized_antecedent, normalized_consequent)
|
||||
::Post.tag_match(normalized_antecedent.join(" ")).find_each do |post|
|
||||
post.reload
|
||||
|
||||
Reference in New Issue
Block a user