Sha256: f23264324fa1cab0eb95027ae01630435be581758aa94b020e0c552b1225c88e

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

module RailsLiveDashboard
  module Recorders
    module Jobs
      class EnqueueRecorder
        def initialize(event)
          @event = event
        end

        def execute
          Job.create(
            batch_id: Current.batch_id,
            content: build_content
          )
        end

        private

        def build_content
          {
            job_name: @event.payload[:job].class,
            job_id: @event.payload[:job].job_id,
            params: @event.payload[:job].arguments || {},
            status: :enqueued,
            queue_name: @event.payload[:job].queue_name,
            history: build_history
          }
        end

        def build_history
          [
            {
              status: :enqueued,
              date: Time.now
            }
          ]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_live_dashboard-0.2.0 lib/rails_live_dashboard/recorders/jobs/enqueue_recorder.rb