FIX: Turn off auto bumping for topics with scheduled bumps

If a topic has a timer scheduled to bump a topic it should be excluded
from being auto bumped.
This commit is contained in:
Blake Erickson
2019-11-19 07:24:18 -07:00
parent 7886a3e58a
commit 266e486037
4 changed files with 42 additions and 0 deletions

View File

@@ -532,6 +532,7 @@ class Category < ActiveRecord::Base
topic = relation
.visible
.listable_topics
.exclude_scheduled_bump_topics
.where(category_id: self.id)
.where('id <> ?', self.topic_id)
.where('bumped_at < ?', 1.day.ago)

View File

@@ -158,6 +158,8 @@ class Topic < ActiveRecord::Base
scope :created_since, lambda { |time_ago| where('topics.created_at > ?', time_ago) }
scope :exclude_scheduled_bump_topics, -> { where.not(id: TopicTimer.scheduled_bump_topics) }
scope :secured, lambda { |guardian = nil|
ids = guardian.secure_category_ids if guardian

View File

@@ -17,6 +17,8 @@ class TopicTimer < ActiveRecord::Base
validate :ensure_update_will_happen
scope :scheduled_bump_topics, -> { where(status_type: 6, deleted_at: nil).pluck(:topic_id) }
before_save do
self.created_at ||= Time.zone.now if execute_at
self.public_type = self.public_type?