aliases/implications: remove forum topic updating code.

Remove code for updating forum topics when an alias or implication is
approved or rejected. This code was only used when approving single
alias or implication requests. This is no longer used now that all
alias/implication requests are done through BURs.
This commit is contained in:
evazion
2020-03-10 20:48:08 -05:00
parent 6504d44223
commit 0e7632ed8a
12 changed files with 20 additions and 202 deletions

View File

@@ -67,8 +67,7 @@ class BulkUpdateRequest < ApplicationRecord
ForumUpdater.new(
forum_topic,
forum_post: post,
expected_title: title,
skip_update: !TagRelationship::SUPPORT_HARD_CODED
expected_title: title
)
end
end
@@ -88,10 +87,6 @@ class BulkUpdateRequest < ApplicationRecord
end
end
def date_timestamp
Time.now.strftime("%Y-%m-%d")
end
def create_forum_topic
CurrentUser.as(user) do
self.forum_topic = ForumTopic.create(title: title, category_id: 1, creator: user) unless forum_topic.present?

View File

@@ -5,32 +5,13 @@ class TagAlias < TagRelationship
validate :wiki_pages_present, on: :create, unless: :skip_secondary_validations
module ApprovalMethods
def approve!(approver: CurrentUser.user, update_topic: true)
def approve!(approver: CurrentUser.user)
update(approver: approver, status: "queued")
ProcessTagAliasJob.perform_later(self, update_topic: update_topic)
end
end
module ForumMethods
def forum_updater
@forum_updater ||= begin
post = if forum_topic
forum_post || forum_topic.posts.where("body like ?", TagAliasRequest.command_string(antecedent_name, consequent_name, id) + "%").last
else
nil
end
ForumUpdater.new(
forum_topic,
forum_post: post,
expected_title: "Tag alias: #{antecedent_name} -> #{consequent_name}",
skip_update: !TagRelationship::SUPPORT_HARD_CODED
)
end
ProcessTagAliasJob.perform_later(self)
end
end
include ApprovalMethods
include ForumMethods
def self.to_aliased(names)
names = Array(names).map(&:to_s)
@@ -39,7 +20,7 @@ class TagAlias < TagRelationship
names.map { |name| aliases[name] || name }
end
def process!(update_topic: true)
def process!
unless valid?
raise errors.full_messages.join("; ")
end
@@ -50,13 +31,11 @@ class TagAlias < TagRelationship
move_saved_searches
ensure_category_consistency
update_posts
forum_updater.update(approval_message(approver), "APPROVED") if update_topic
rename_wiki_and_artist
update!(status: "active")
end
rescue Exception => e
CurrentUser.scoped(approver) do
forum_updater.update(failure_message(e), "FAILED") if update_topic
update(status: "error: #{e}")
end
@@ -122,8 +101,6 @@ class TagAlias < TagRelationship
if antecedent_wiki.present?
if WikiPage.titled(consequent_name).blank?
antecedent_wiki.update!(title: consequent_name)
else
forum_updater.update(conflict_message)
end
end
@@ -136,7 +113,7 @@ class TagAlias < TagRelationship
def wiki_pages_present
if antecedent_wiki.present? && consequent_wiki.present?
errors[:base] << conflict_message
errors[:base] << "The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] has conflicting wiki pages. [[#{consequent_name}]] should be updated to include information from [[#{antecedent_name}]] if necessary."
elsif antecedent_wiki.blank? && consequent_wiki.blank?
errors[:base] << "The #{consequent_name} tag needs a corresponding wiki page"
end

View File

@@ -120,7 +120,7 @@ class TagImplication < TagRelationship
end
module ApprovalMethods
def process!(update_topic: true)
def process!
unless valid?
raise errors.full_messages.join("; ")
end
@@ -129,18 +129,15 @@ class TagImplication < TagRelationship
update(status: "processing")
update_posts
update(status: "active")
forum_updater.update(approval_message(approver), "APPROVED") if update_topic
end
rescue Exception => e
forum_updater.update(failure_message(e), "FAILED") if update_topic
update(status: "error: #{e}")
DanbooruLogger.log(e, tag_implication_id: id, antecedent_name: antecedent_name, consequent_name: consequent_name)
end
def approve!(approver: CurrentUser.user, update_topic: true)
def approve!(approver: CurrentUser.user)
update(approver: approver, status: "queued")
ProcessTagImplicationJob.perform_later(self, update_topic: update_topic)
ProcessTagImplicationJob.perform_later(self)
end
def create_mod_action
@@ -162,20 +159,6 @@ class TagImplication < TagRelationship
ModAction.log("updated #{implication}\n#{change_desc}", :tag_implication_update)
end
end
def forum_updater
post = if forum_topic
forum_post || forum_topic.posts.where("body like ?", TagImplicationRequest.command_string(antecedent_name, consequent_name, id) + "%").last
else
nil
end
ForumUpdater.new(
forum_topic,
forum_post: post,
expected_title: "Tag implication: #{antecedent_name} -> #{consequent_name}",
skip_update: !TagRelationship::SUPPORT_HARD_CODED
)
end
end
include DescendantMethods

View File

@@ -1,7 +1,6 @@
class TagRelationship < ApplicationRecord
self.abstract_class = true
SUPPORT_HARD_CODED = true
EXPIRY = 60
EXPIRY_WARNING = 55
@@ -69,11 +68,8 @@ class TagRelationship < ApplicationRecord
user.is_admin?
end
def reject!(update_topic: true)
transaction do
update!(status: "deleted")
forum_updater.update(reject_message(CurrentUser.user), "REJECTED") if update_topic
end
def reject!
update!(status: "deleted")
end
module SearchMethods
@@ -145,32 +141,8 @@ class TagRelationship < ApplicationRecord
self.class.name.underscore.tr("_", " ")
end
def approval_message(approver)
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] #{forum_link} has been approved by @#{approver.name}."
end
def failure_message(e = nil)
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] #{forum_link} failed during processing. Reason: #{e}"
end
def reject_message(rejector)
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] #{forum_link} has been rejected by @#{rejector.name}."
end
def retirement_message
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] #{forum_link} has been retired."
end
def conflict_message
"The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] #{forum_link} has conflicting wiki pages. [[#{consequent_name}]] should be updated to include information from [[#{antecedent_name}]] if necessary."
end
def date_timestamp
Time.now.strftime("%Y-%m-%d")
end
def forum_link
"(forum ##{forum_post.id})" if forum_post.present?
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] has been retired."
end
end