From 3e80e885aedc6a706426c1dc15e6fefbcce3a1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sun, 8 Sep 2013 12:22:50 +0200 Subject: [PATCH] rake task to regenerate avatars --- config/locales/server.en.yml | 2 +- lib/tasks/avatars.rake | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lib/tasks/avatars.rake diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 6c727809949..e37bc6254e4 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -669,7 +669,7 @@ en: username_change_period: "The number of days after registration that accounts can change their username." allow_uploaded_avatars: "Allow users to upload their custom avatars" - allow_animated_avatars: "Allow users to use animated gif for avatars" + allow_animated_avatars: "Allow users to use animated gif for avatars. WARNING: it is highly recommended to run the avatars:regenerate rake task after changing that setting." default_digest_email_frequency: "How often users receive digest emails by default. They can change this setting in their preferences." notification_types: diff --git a/lib/tasks/avatars.rake b/lib/tasks/avatars.rake new file mode 100644 index 00000000000..037b766a869 --- /dev/null +++ b/lib/tasks/avatars.rake @@ -0,0 +1,13 @@ +desc "re-generate avatars" +task "avatars:regenerate" => :environment do + RailsMultisite::ConnectionManagement.each_connection do |db| + puts "Generating avatars for: #{db}" + + User.select(:uploaded_avatar_id).where("uploaded_avatar_id IS NOT NULL").all.each do |u| + Jobs.enqueue(:generate_avatars, upload_id: u.uploaded_avatar_id) + putc "." + end + + end + puts "\ndone." +end