mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 02:38:54 +08:00
FEATURE: rake task to clean up all the avatar thumbnails
This commit is contained in:
parent
4321ccd761
commit
6b607d0d3b
@ -6,7 +6,20 @@ task "avatars:refresh" => :environment do
|
||||
User.find_each do |user|
|
||||
user.refresh_avatar
|
||||
user.user_avatar.update_gravatar!
|
||||
putc "." if (i+=1)%10 == 0
|
||||
putc "." if (i += 1) % 10 == 0
|
||||
end
|
||||
puts
|
||||
end
|
||||
|
||||
desc "Clean up all avatar thumbnails (use this when the thumbnail algorithm changes)"
|
||||
task "avatars:clean" => :environment do
|
||||
i = 0
|
||||
puts "Cleaning up avatar thumbnails"
|
||||
puts
|
||||
custom_upload_ids = UserAvatar.where.not(custom_upload_id: nil).pluck(:custom_upload_id)
|
||||
OptimizedImage.where("upload_id IN (?)", custom_upload_ids).find_each do |optimized_image|
|
||||
optimized_image.destroy!
|
||||
putc "." if (i += 1) % 10 == 0
|
||||
end
|
||||
puts
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user