mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 23:06:57 +08:00
427d54b2b0
Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. We no longer need to use Rails "require_dependency" anywhere and instead can just use standard Ruby patterns to require files. This is a far reaching change and we expect some followups here.
31 lines
1.1 KiB
Ruby
31 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
|
|
class MigrateFeaturedLinks < ::Jobs::Onceoff
|
|
|
|
def execute_onceoff(args)
|
|
TopicCustomField.where(name: "featured_link").find_each do |tcf|
|
|
if tcf.value.present?
|
|
Topic.where(id: tcf.topic_id).update_all(featured_link: tcf.value)
|
|
end
|
|
end
|
|
|
|
# Plugin behaviour: only categories explicitly allowed to have featured links can have them.
|
|
# All others implicitly DO NOT allow them.
|
|
# If no categories were explicitly allowed to have them, then all implicitly DID allow them.
|
|
|
|
allowed = CategoryCustomField.where(name: "topic_featured_link_allowed").where(value: "true").pluck(:category_id)
|
|
|
|
if !allowed.empty?
|
|
# all others are not allowed
|
|
Category.where.not(id: allowed).update_all(topic_featured_link_allowed: false)
|
|
else
|
|
not_allowed = CategoryCustomField.where(name: "topic_featured_link_allowed").where.not(value: "true").pluck(:category_id)
|
|
Category.where(id: not_allowed).update_all(topic_featured_link_allowed: false)
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|