Sha256: 42a981a6b99e820c224c11e1ab6d4291bd9b3553c731ff2d7ad37ac568d8d8c7

Contents?: true

Size: 763 Bytes

Versions: 1

Compression:

Stored size: 763 Bytes

Contents

module QPush
  module Server
    module Apis
      class History < Base
        def initialize(job, status, error)
          @status = status
          @klass = job.klass
          @args = job.args
          @performed = Time.now.to_i
          @error = error ? error.message : nil
        end

        def call
          update_history
        end

        private

        def update_history
          QPush.redis.with do |c|
            c.lpush(QPush.keys.history, to_json)
            c.ltrim(QPush.keys.history, 0, 10)
          end
        end

        def to_json
          { status: @status,
            klass: @klass,
            args: @args,
            performed: @performed,
            error: @error }.to_json
        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/history.rb