BURs: don't log mod actions for aliases/implications/mass updates.

Don't log mod actions when aliases, implications, or mass updates are
processed.

Originally aliases and implications were logged because they could be
approved outside of a BUR. Mass updates could also be performed by mods
without making a forum request. This is no longer the case.

They were also logged for debugging purposes. This is no longer needed.
This generated a lot of spam in the mod action logs when a large BUR was
approved.
This commit is contained in:
evazion
2020-12-02 12:20:28 -06:00
parent 33c9d34927
commit 9e37f5a588
5 changed files with 3 additions and 51 deletions

View File

@@ -7,7 +7,6 @@ class TagBatchChangeJob < ApplicationJob
CurrentUser.scoped(User.system) do
migrate_posts(normalized_antecedent, normalized_consequent)
ModAction.log("processed mass update: #{antecedent} -> #{consequent}", :mass_update)
end
end

View File

@@ -41,13 +41,13 @@ class ModAction < ApplicationRecord
forum_post_update: 101,
forum_post_delete: 102,
tag_alias_create: 120,
tag_alias_update: 121,
tag_alias_update: 121, # XXX unused
tag_implication_create: 140,
tag_implication_update: 141,
tag_implication_update: 141, # XXX unused
ip_ban_create: 160,
ip_ban_delete: 162,
ip_ban_undelete: 163,
mass_update: 1000,
mass_update: 1000, # XXX unused
bulk_revert: 1001, # XXX unused
other: 2000
}

View File

@@ -1,5 +1,4 @@
class TagAlias < TagRelationship
after_save :create_mod_action
validates_uniqueness_of :antecedent_name, scope: :status, conditions: -> { active }
validate :absence_of_transitive_relation
@@ -23,24 +22,4 @@ class TagAlias < TagRelationship
errors[:base] << "A tag alias for #{consequent_name} already exists"
end
end
def create_mod_action
alias_desc = %("tag alias ##{id}":[#{Rails.application.routes.url_helpers.tag_alias_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]])
if saved_change_to_id?
ModAction.log("created #{status} #{alias_desc}", :tag_alias_create)
else
# format the changes hash more nicely.
change_desc = saved_changes.except(:updated_at).map do |attribute, values|
old, new = values[0], values[1]
if old.nil?
%(set #{attribute} to "#{new}")
else
%(changed #{attribute} from "#{old}" to "#{new}")
end
end.join(", ")
ModAction.log("updated #{alias_desc}\n#{change_desc}", :tag_alias_update)
end
end
end

View File

@@ -2,7 +2,6 @@ class TagImplication < TagRelationship
has_many :child_implications, class_name: "TagImplication", primary_key: :consequent_name, foreign_key: :antecedent_name
has_many :parent_implications, class_name: "TagImplication", primary_key: :antecedent_name, foreign_key: :consequent_name
after_save :create_mod_action
validates :antecedent_name, uniqueness: { scope: [:consequent_name, :status], conditions: -> { active }}
validate :absence_of_circular_relation
validate :absence_of_transitive_relation
@@ -121,26 +120,6 @@ class TagImplication < TagRelationship
end
end
end
def create_mod_action
implication = %("tag implication ##{id}":[#{Rails.application.routes.url_helpers.tag_implication_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]])
if saved_change_to_id?
ModAction.log("created #{status} #{implication}", :tag_implication_create)
else
# format the changes hash more nicely.
change_desc = saved_changes.except(:updated_at).map do |attribute, values|
old, new = values[0], values[1]
if old.nil?
%(set #{attribute} to "#{new}")
else
%(changed #{attribute} from "#{old}" to "#{new}")
end
end.join(", ")
ModAction.log("updated #{implication}\n#{change_desc}", :tag_implication_update)
end
end
end
include DescendantMethods

View File

@@ -11,10 +11,5 @@ class TagBatchChangeJobTest < ActiveJob::TestCase
TagBatchChangeJob.perform_now("aaa", "bbb")
assert_equal("bbb", @post.reload.tag_string)
end
should "log a modaction" do
TagBatchChangeJob.perform_now("1", "2")
assert_equal("mass_update", ModAction.last.category)
end
end
end