docbrown/app/workers/articles/enrich_image_attributes_worker.rb
Ben Halpern 2395693809
Asynchronously detect image aspect ratios and apply proper attributes (#15170)
* Initial work to expand detection functionality

* Finish up functionality and tests

* Fix class name

* Fix tests

* Update spec/services/articles/enrich_image_attributes_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Update spec/services/articles/enrich_image_attributes_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-10-26 13:39:25 -07:00

17 lines
419 B
Ruby

module Articles
class EnrichImageAttributesWorker
include Sidekiq::Worker
sidekiq_options queue: :medium_priority, retry: 5, lock: :until_executing
def perform(article_id)
article = Article.find_by(id: article_id)
return unless article
detected = Articles::EnrichImageAttributes.call(article)
return unless detected
EdgeCache::BustArticle.call(article)
end
end
end