Merge pull request #4420 from tgxworld/prioritize_user_avataras
Prioritize user avatars when regenerating missing optimized images.
This commit is contained in:
commit
b1c8ede617
|
@ -390,11 +390,20 @@ def regenerate_missing_optimized
|
||||||
public_directory = "#{Rails.root}/public"
|
public_directory = "#{Rails.root}/public"
|
||||||
missing_uploads = Set.new
|
missing_uploads = Set.new
|
||||||
|
|
||||||
OptimizedImage.includes(:upload)
|
avatar_upload_ids = UserAvatar.all.pluck(:custom_upload_id, :gravatar_upload_id).flatten.compact
|
||||||
|
|
||||||
|
default_scope = OptimizedImage.includes(:upload)
|
||||||
|
|
||||||
|
[
|
||||||
|
default_scope
|
||||||
|
.where("optimized_images.upload_id IN (?)", avatar_upload_ids),
|
||||||
|
|
||||||
|
default_scope
|
||||||
|
.where("optimized_images.upload_id NOT IN (?)", avatar_upload_ids)
|
||||||
.where("LENGTH(COALESCE(url, '')) > 0")
|
.where("LENGTH(COALESCE(url, '')) > 0")
|
||||||
.where("width > 0 AND height > 0")
|
.where("width > 0 AND height > 0")
|
||||||
.find_each do |optimized_image|
|
].each do |scope|
|
||||||
|
scope.find_each do |optimized_image|
|
||||||
upload = optimized_image.upload
|
upload = optimized_image.upload
|
||||||
|
|
||||||
next unless optimized_image.url =~ /^\/[^\/]/
|
next unless optimized_image.url =~ /^\/[^\/]/
|
||||||
|
@ -430,6 +439,7 @@ def regenerate_missing_optimized
|
||||||
putc "."
|
putc "."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
puts "", "Done"
|
puts "", "Done"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue