Sha256: e65129698c260f20e1711cad1e602fea76129f5976eaeb7c9e134d974d903b2a

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

# rake effective_polls:notify

namespace :effective_polls do
  desc 'Send email notifications for effective polls'
  task notify: :environment do
    poll_notifications = Effective::PollNotification.all.deep.notifiable

    poll_notifications.find_each do |poll_notification|
      begin
        notified = poll_notification.notify!
        puts "Sent #{poll_notification.category} for #{poll_notification.poll}" if notified
      rescue => e
        if defined?(ExceptionNotifier)
          data = { poll_notification_id: poll_notification.id, poll_id: poll_notification.poll_id }
          ExceptionNotifier.notify_exception(e, data: data)
        end

        puts "Error with effective poll_notification #{poll_notification.id}: #{e.errors.inspect}"
      end
    end

    puts 'All done'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
effective_polls-0.0.2 lib/tasks/effective_polls_tasks.rake
effective_polls-0.0.1 lib/tasks/effective_polls_tasks.rake