Sha256: ad99eac24f672bd81190d9e4923b8bf8e043e2182e4c866934d93aa1d48a29eb

Contents?: true

Size: 1.06 KB

Versions: 67

Compression:

Stored size: 1.06 KB

Contents

module UINotifications
  module Tasks
    class TaskBulkResume < ::UINotifications::Base
      def initialize(task, resumed_length, failed_length, skipped_length)
        @subject = task
        @resumed_length = resumed_length
        @failed_length = failed_length
        @skipped_length = skipped_length
      end

      def create
        Notification.create!(
          initiator: initiator,
          audience: audience,
          subject: subject,
          notification_blueprint: blueprint,
          message: message,
          notification_recipients: [NotificationRecipient.create({ :user => User.current })]
        )
      end

      def audience
        Notification::AUDIENCE_USER
      end

      def message
        ('%{resumed} Tasks were resumed. %{failed} Tasks failed to resume. %{skipped} Tasks were skipped. ' %
          { resumed: @resumed_length,
          failed: @failed_length,
          skipped: @skipped_length })
      end

      def blueprint
        @blueprint ||= NotificationBlueprint.find_by(name: 'tasks_bulk_resume')
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
foreman-tasks-5.2.0 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-5.1.1 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-5.1.0 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-4.1.5 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-4.1.4 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-4.1.3 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-3.0.6 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-5.0.0 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-4.1.2 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-4.1.1 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-4.0.1 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-4.1.0 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-3.0.5 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-4.0.0 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-3.0.4 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-2.0.3 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-3.0.3 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-3.0.2 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-3.0.1 app/services/ui_notifications/tasks/task_bulk_resume.rb
foreman-tasks-3.0.0 app/services/ui_notifications/tasks/task_bulk_resume.rb