From 6dd1e313374983d0936d8964a6ac9c7a5c2139d9 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Sun, 10 Aug 2014 00:11:17 +0300 Subject: [PATCH] Rake task for Notifier.admin to send emails to users --- lib/tasks/podmin.rake | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/tasks/podmin.rake diff --git a/lib/tasks/podmin.rake b/lib/tasks/podmin.rake new file mode 100644 index 000000000..f48f042a3 --- /dev/null +++ b/lib/tasks/podmin.rake @@ -0,0 +1,29 @@ +namespace :podmin do + + desc < :environment do |t, args| + if args[:users_def] == 'all' + # to all except deleted and deactivated, of course + users = User.where(locked_at: nil) + elsif args[:users_def] == 'active_yearly' + users = User.yearly_actives + elsif args[:users_def] == 'active_monthly' + users = User.monthly_actives + elsif args[:users_def] == 'active_halfyear' + users = User.halfyear_actives + end + file = File.open(args[:msg_path]) + msg = file.read + file.close + mails = Notifier.admin(msg.html_safe, users) + mails.each(&:deliver) + end + +end \ No newline at end of file