Sha256: 98c822bddb20cf49c4b73ca6f89733b42596a5db8a7ab9c737ec944c7a9fbd17

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

module QPush
  module Server
    module Apis
      class Success < Base
        def initialize(job)
          @job = job
        end

        def call
          update_job
          stat_increment
          log_success
          update_history
        end

        private

        def update_job
          @job.mark_success
          @job.delay if @job.delay_job?
        end

        def stat_increment
          QPush.redis.with do |c|
            c.hincrby(QPush.keys.stats, 'success', 1)
          end
        end

        def log_success
          Server.log.info("Job SUCCESS | #{@job.klass} with ID: #{@job.id} | #{@job.run_time}")
        end

        def update_history
          History.call(@job, true, nil)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qpush-0.1.4 lib/qpush/server/apis/success.rb