From d0057e490fcec530ff0dc15225571a7e4e9875ba Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Fri, 30 Oct 2020 18:27:58 +0100 Subject: [PATCH] Task added to precompute image variants --- lib/tasks/preprocess_image_variants.rake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/tasks/preprocess_image_variants.rake diff --git a/lib/tasks/preprocess_image_variants.rake b/lib/tasks/preprocess_image_variants.rake new file mode 100644 index 0000000..8bf6c1c --- /dev/null +++ b/lib/tasks/preprocess_image_variants.rake @@ -0,0 +1,14 @@ +namespace :debshots do + desc "Preprocess image variants to speed up loading times" + + task preprocess_image_variants: :environment do + + ss = Screenshot.all.each do |ss| + return unless ss.image.attached? + + Rails.logger.info "Processed variants for #{ss.id} of #{ss.package.name}" + ss.medium_image + ss.large_image_watermarked + end + end +end