mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 17:53:23 +08:00
87ec058b8b
Currently the auto-bump cooldown is hard-coded to 24 hours. This change makes the highlighted 24 hours part configurable (defaulting to 24 hours), and the rest of the process remains the same. This uses the new CategorySetting model associated with Category. We decided to add this because we want to move away from custom fields due to the lack of type casting and validations, but we want to keep the loading of these optional as they are not needed for almost all of the flows. Category settings will be back-filled to all categories as part of this change, and creating a new category will now also create a category setting.
37 lines
1007 B
Ruby
37 lines
1007 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CategorySetting < ActiveRecord::Base
|
|
belongs_to :category
|
|
|
|
validates :num_auto_bump_daily,
|
|
numericality: {
|
|
only_integer: true,
|
|
greater_than_or_equal_to: 0,
|
|
allow_nil: true,
|
|
}
|
|
|
|
validates :auto_bump_cooldown_days,
|
|
numericality: {
|
|
only_integer: true,
|
|
greater_than_or_equal_to: 0,
|
|
allow_nil: true,
|
|
}
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: category_settings
|
|
#
|
|
# id :bigint not null, primary key
|
|
# category_id :bigint not null
|
|
# require_topic_approval :boolean
|
|
# require_reply_approval :boolean
|
|
# num_auto_bump_daily :integer
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# auto_bump_cooldown_days :integer default(1)
|
|
# Indexes
|
|
#
|
|
# index_category_settings_on_category_id (category_id) UNIQUE
|
|
#
|