2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-11 03:27:33 -05:00
|
|
|
module Jobs
|
2019-10-02 00:01:53 -04:00
|
|
|
class FixFeaturedLinkForTopics < ::Jobs::Onceoff
|
2017-12-11 03:27:33 -05:00
|
|
|
def execute_onceoff(args)
|
|
|
|
Topic.where("featured_link IS NOT NULL").find_each do |topic|
|
|
|
|
featured_link = topic.featured_link
|
|
|
|
|
|
|
|
begin
|
|
|
|
URI.parse(featured_link)
|
2018-08-14 06:23:32 -04:00
|
|
|
rescue URI::Error
|
2019-04-29 03:32:25 -04:00
|
|
|
topic.update(featured_link: URI.extract(featured_link).first)
|
2017-12-11 03:27:33 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|