mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-04 21:01:27 -05:00
0634834009
* FIX: No need to manually include relation. * FIX: OR instead of chaining relation.
33 lines
862 B
Ruby
33 lines
862 B
Ruby
desc "Refresh all avatars (download missing gravatars, refresh system)"
|
|
task "avatars:refresh" => :environment do
|
|
i = 0
|
|
|
|
puts "Refreshing avatars"
|
|
puts
|
|
|
|
User.find_each do |user|
|
|
user.refresh_avatar
|
|
user.user_avatar.update_gravatar!
|
|
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
|
|
|
|
OptimizedImage.where("upload_id IN (SELECT custom_upload_id FROM user_avatars) OR
|
|
upload_id IN (SELECT gravatar_upload_id FROM user_avatars) OR
|
|
upload_id IN (SELECT uploaded_avatar_id FROM users)")
|
|
.find_each do |optimized_image|
|
|
optimized_image.destroy!
|
|
putc "." if (i += 1) % 10 == 0
|
|
end
|
|
|
|
puts
|
|
end
|