Sha256: 03f91366040743e387a844f5b85426f7f753e0108e953904f269ad7e8d0ed9f3

Contents?: true

Size: 966 Bytes

Versions: 64

Compression:

Stored size: 966 Bytes

Contents

module UINotifications
  module Tasks
    class TaskBulkStop < ::UINotifications::Base
      def initialize(task, stopped_length, skipped_length)
        @subject = task
        @stopped_length = stopped_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_GLOBAL
      end

      def message
        ('%{stopped} Tasks were stopped. %{skipped} Tasks were already stopped. ' %
          { stopped: @stopped_length,
          skipped: @skipped_length })
      end

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

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
foreman-tasks-10.0.1 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-10.0.0 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.2.3 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.2.2 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.2.1 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.2.0 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.1.1 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.0.4 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.1.0 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.0.2 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.0.1 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-8.3.3 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-9.0.0 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-8.2.1 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-8.1.4 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-8.3.2 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-8.3.1 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-8.1.3 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-8.3.0 app/services/ui_notifications/tasks/task_bulk_stop.rb
foreman-tasks-8.2.0 app/services/ui_notifications/tasks/task_bulk_stop.rb