change formatting for modactions on alias/implication update + add mod action for tag batch changes
This commit is contained in:
@@ -20,6 +20,10 @@ class BulkRevert
|
|||||||
@_preview ||= find_post_versions
|
@_preview ||= find_post_versions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def query_gbq(user_id, added_tags, removed_tags, min_version_id, max_version_id)
|
||||||
|
GoogleBigQuery::PostVersion.new.find(user_id, added_tags, removed_tags, min_version_id, max_version_id, BIG_QUERY_LIMIT)
|
||||||
|
end
|
||||||
|
|
||||||
def find_post_versions
|
def find_post_versions
|
||||||
q = PostVersion.where("true")
|
q = PostVersion.where("true")
|
||||||
|
|
||||||
@@ -34,7 +38,7 @@ class BulkRevert
|
|||||||
if constraints[:added_tags] || constraints[:removed_tags]
|
if constraints[:added_tags] || constraints[:removed_tags]
|
||||||
hash = CityHash.hash64("#{constraints[:added_tags]} #{constraints{removed_tags}} #{constraints[:min_version_id]} #{constraints[:max_version_id]}").to_s(36)
|
hash = CityHash.hash64("#{constraints[:added_tags]} #{constraints{removed_tags}} #{constraints[:min_version_id]} #{constraints[:max_version_id]}").to_s(36)
|
||||||
sub_ids = Cache.get("br/fpv/#{hash}", 300) do
|
sub_ids = Cache.get("br/fpv/#{hash}", 300) do
|
||||||
GoogleBigQuery::PostVersion.new.find(constraints[:user_id], constraints[:added_tags], constraints[:removed_tags], constraints[:min_version_id], constraints[:max_version_id], BIG_QUERY_LIMIT)
|
query_gbq(constraints[:user_id], constraints[:added_tags], constraints[:removed_tags], constraints[:min_version_id], constraints[:max_version_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
if sub_ids.size >= BIG_QUERY_LIMIT
|
if sub_ids.size >= BIG_QUERY_LIMIT
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ module Moderator
|
|||||||
|
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
CurrentUser.scoped(updater, updater_ip_addr) do
|
CurrentUser.scoped(updater, updater_ip_addr) do
|
||||||
|
ModAction.create(:description => "processed mass update: #{antecedent} -> #{consequent}")
|
||||||
|
|
||||||
::Post.tag_match(antecedent).where("true /* Moderator::TagBatchChange#perform */").find_each do |post|
|
::Post.tag_match(antecedent).where("true /* Moderator::TagBatchChange#perform */").find_each do |post|
|
||||||
post.reload
|
post.reload
|
||||||
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
||||||
|
|||||||
@@ -326,10 +326,10 @@ class TagAlias < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_mod_action
|
def create_mod_action
|
||||||
alias_desc = %Q("tag alias ##{id}":[#{Rails.application.routes.url_helpers.tag_alias_path(self)}] ([[#{antecedent_name}]] -> [[#{consequent_name}]]))
|
alias_desc = %Q("tag alias ##{id}":[#{Rails.application.routes.url_helpers.tag_alias_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]])
|
||||||
|
|
||||||
if id_changed?
|
if id_changed?
|
||||||
ModAction.create(:description => "created #{status} #{alias_desc}.")
|
ModAction.create(:description => "created #{status} #{alias_desc}")
|
||||||
else
|
else
|
||||||
# format the changes hash more nicely.
|
# format the changes hash more nicely.
|
||||||
change_desc = changes.except(:updated_at).map do |attribute, values|
|
change_desc = changes.except(:updated_at).map do |attribute, values|
|
||||||
@@ -341,7 +341,7 @@ class TagAlias < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end.join(", ")
|
end.join(", ")
|
||||||
|
|
||||||
ModAction.create(:description => "updated #{alias_desc}: #{change_desc}.")
|
ModAction.create(:description => "updated #{alias_desc}\n#{change_desc}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -294,10 +294,10 @@ class TagImplication < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_mod_action
|
def create_mod_action
|
||||||
implication = %Q("tag implication ##{id}":[#{Rails.application.routes.url_helpers.tag_implication_path(self)}] ([[#{antecedent_name}]] -> [[#{consequent_name}]]))
|
implication = %Q("tag implication ##{id}":[#{Rails.application.routes.url_helpers.tag_implication_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]])
|
||||||
|
|
||||||
if id_changed?
|
if id_changed?
|
||||||
ModAction.create(:description => "created #{status} #{implication}.")
|
ModAction.create(:description => "created #{status} #{implication}")
|
||||||
else
|
else
|
||||||
# format the changes hash more nicely.
|
# format the changes hash more nicely.
|
||||||
change_desc = changes.except(:updated_at).map do |attribute, values|
|
change_desc = changes.except(:updated_at).map do |attribute, values|
|
||||||
@@ -309,7 +309,7 @@ class TagImplication < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end.join(", ")
|
end.join(", ")
|
||||||
|
|
||||||
ModAction.create(:description => "updated #{implication}: #{change_desc}.")
|
ModAction.create(:description => "updated #{implication}\n#{change_desc}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user