Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add task to eagerly generate ingredients pictures thumbnails #2342

Merged
merged 2 commits into from
May 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lib/tasks/alchemy/thumbnails.rake
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,29 @@ namespace :alchemy do

puts "Done!"
end

desc "Generates thumbnails for Alchemy Picture Ingredients (set ELEMENTS=element1,element2 to only generate thumbnails for a subset of elements)."
task ingredient_picture_thumbnails: :environment do
ingredient_pictures = Alchemy::Ingredients::Picture.
joins(:element).
preload({ related_object: :thumbs }).
merge(Alchemy::Element.available)

if ENV["ELEMENTS"].present?
ingredient_pictures = ingredient_pictures.merge(
Alchemy::Element.named(ENV["ELEMENTS"].split(","))
)
end

puts "Regenerate #{ingredient_pictures.count} ingredient picture thumbnails."
puts "Please wait..."

ingredient_pictures.find_each do |ingredient_picture|
puts ingredient_picture.picture_url
puts ingredient_picture.thumbnail_url
end

puts "Done!"
end
end
end