From eddf2e59f00fcc1c657e0ef6baf569c6718a156a Mon Sep 17 00:00:00 2001 From: Albert Yi Date: Mon, 5 Dec 2016 14:46:02 -0800 Subject: [PATCH] change formatting for modactions on alias/implication update + add mod action for tag batch changes --- app/logical/bulk_revert.rb | 6 +++++- app/logical/moderator/tag_batch_change.rb | 2 ++ app/models/tag_alias.rb | 6 +++--- app/models/tag_implication.rb | 6 +++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/logical/bulk_revert.rb b/app/logical/bulk_revert.rb index 191d446d4..932afda83 100644 --- a/app/logical/bulk_revert.rb +++ b/app/logical/bulk_revert.rb @@ -20,6 +20,10 @@ class BulkRevert @_preview ||= find_post_versions 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 q = PostVersion.where("true") @@ -34,7 +38,7 @@ class BulkRevert 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) 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 if sub_ids.size >= BIG_QUERY_LIMIT diff --git a/app/logical/moderator/tag_batch_change.rb b/app/logical/moderator/tag_batch_change.rb index 56fd204e5..dd8b90bf9 100644 --- a/app/logical/moderator/tag_batch_change.rb +++ b/app/logical/moderator/tag_batch_change.rb @@ -12,6 +12,8 @@ module Moderator CurrentUser.without_safe_mode 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.reload tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ") diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index d83752450..34e200d0f 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -326,10 +326,10 @@ class TagAlias < ActiveRecord::Base end 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? - ModAction.create(:description => "created #{status} #{alias_desc}.") + ModAction.create(:description => "created #{status} #{alias_desc}") else # format the changes hash more nicely. change_desc = changes.except(:updated_at).map do |attribute, values| @@ -341,7 +341,7 @@ class TagAlias < ActiveRecord::Base end end.join(", ") - ModAction.create(:description => "updated #{alias_desc}: #{change_desc}.") + ModAction.create(:description => "updated #{alias_desc}\n#{change_desc}") end end end diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index 53c76cebc..b54f94a31 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -294,10 +294,10 @@ class TagImplication < ActiveRecord::Base end 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? - ModAction.create(:description => "created #{status} #{implication}.") + ModAction.create(:description => "created #{status} #{implication}") else # format the changes hash more nicely. change_desc = changes.except(:updated_at).map do |attribute, values| @@ -309,7 +309,7 @@ class TagImplication < ActiveRecord::Base end end.join(", ") - ModAction.create(:description => "updated #{implication}: #{change_desc}.") + ModAction.create(:description => "updated #{implication}\n#{change_desc}") end end end