FIX: Only delete featured topics if the status changes to a hidden one

This commit is contained in:
Robin Ward 2016-05-24 14:27:48 -04:00
parent d804b47725
commit a38050a272
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D
1 changed files with 8 additions and 4 deletions

View File

@ -25,9 +25,13 @@ TopicStatusUpdate = Struct.new(:topic, :user) do
topic.reload.set_auto_close(nil).save
end
# pick up the changes right away as opposed to waiting for
# the schedule
CategoryFeaturedTopic.feature_topics_for(topic.category)
# remove featured topics if we close/archive/make them invisible. Previously we used
# to run the whole featuring logic but that could be very slow and have concurrency
# errors on large sites with many autocloses and topics being created.
if ((status.enabled? && (status.autoclosed? || status.closed? || status.archived?)) ||
(status.disabled? && status.visible?))
CategoryFeaturedTopic.where(topic_id: topic.id).delete_all
end
end
def create_moderator_post_for(status, message=nil)
@ -81,7 +85,7 @@ TopicStatusUpdate = Struct.new(:topic, :user) do
end
Status = Struct.new(:name, :enabled) do
%w(pinned_globally pinned autoclosed closed).each do |status|
%w(pinned_globally pinned autoclosed closed visible archived).each do |status|
define_method("#{status}?") { name == status }
end