Sha256: af8fc5e5a41417aaae6abb52b6910249768ee2efbb17026f917fb2e3e3206cdc

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

module RailsLiveDashboard
  module Recorders
    module Jobs
      class StartRecorder
        def initialize(event)
          @event = event
          @job = Job.same(@event.payload[:job].job_id).first
        end

        def execute
          raise Exceptions::EntryNotFound.new(:job, @event.payload[:job].job_id) if @job.nil?

          Current.batch_id = @job.batch_id

          build_content
          build_history

          @job.update(content:)
        end

        private

        def content
          @content ||= @job.content
        end

        def build_content
          content.status = :started
          content.started_at = Time.now
        end

        def build_history
          content.history.push({
            status: :started,
            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/start_recorder.rb