Merge pull request #4044 from r888888888/tag-change-notices

Tag change notices
This commit is contained in:
Albert Yi
2019-01-24 14:23:35 -08:00
committed by GitHub
12 changed files with 148 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ class BulkUpdateRequest < ApplicationRecord
before_validation :initialize_attributes, :on => :create
before_validation :normalize_text
after_create :create_forum_topic
after_save :update_notice
scope :pending_first, -> { order(Arel.sql("(case status when 'pending' then 0 when 'approved' then 1 else 2 end)")) }
scope :pending, -> {where(status: "pending")}
@@ -241,4 +242,11 @@ class BulkUpdateRequest < ApplicationRecord
def estimate_update_count
AliasAndImplicationImporter.new(script, nil).estimate_update_count
end
def update_notice
TagChangeNoticeService.update_cache(
AliasAndImplicationImporter.new(script, nil).affected_tags,
forum_topic_id
)
end
end

View File

@@ -32,6 +32,7 @@ class TagRelationship < ApplicationRecord
validates :approver, presence: { message: "must exist" }, if: -> { approver_id.present? }
validates :forum_topic, presence: { message: "must exist" }, if: -> { forum_topic_id.present? }
validate :antecedent_and_consequent_are_different
after_save :update_notice
def initialize_creator
self.creator_id = CurrentUser.user.id
@@ -204,6 +205,13 @@ class TagRelationship < ApplicationRecord
Post.fast_count(antecedent_name, skip_cache: true)
end
def update_notice
TagChangeNoticeService.update_cache(
[antecedent_name, consequent_name],
forum_topic_id
)
end
extend SearchMethods
include MessageMethods
end