mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 21:45:25 +08:00
We can't enable `Rails/WhereNot` lint/autofix, because it would break code that uses mini_sql instead of AR (which rubocop, and tbh also we, can't easily differentiate) Those are safe because they either: * are executed in AR model scope definitions * are clearly chained starting from a AR model * are less-clearly chained, but still can be traced to a AR model/scope --------- Co-authored-by: Loïc Guitaut <loic@discourse.org>
19 lines
451 B
Ruby
Vendored
19 lines
451 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class FixFeaturedLinkForTopics < ::Jobs::Onceoff
|
|
def execute_onceoff(args)
|
|
Topic
|
|
.where.not(featured_link: nil)
|
|
.find_each do |topic|
|
|
featured_link = topic.featured_link
|
|
|
|
begin
|
|
URI.parse(featured_link)
|
|
rescue URI::Error
|
|
topic.update(featured_link: URI.extract(featured_link).first)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|