Sha256: 4f8c9986dc9d9565d76459b7bdf5bd8bc4a4fcbe75e848092fb12f1f44087dcb

Contents?: true

Size: 745 Bytes

Versions: 1

Compression:

Stored size: 745 Bytes

Contents

module QPush
  module Web
    module Apis
      class Crons
        def initialize(start, count)
          @jobs = nil
          @start = start ? start.to_i : 0
          @count = count ? count.to_i : 10
        end

        def call
          retrieve_delays
          filter_crons
        end

        private

        def retrieve_delays
          @jobs = QPush.redis.with do |conn|
            conn.zrange(QPush.keys.delay, 0, -1, with_scores: true)
          end
        end

        def filter_crons
          @jobs.map! do |job|
            hash = JSON.parse(job.first).merge(perform_at: job.last)
            hash['cron'].empty? ? next : hash
          end
          @jobs.compact[@start, @count]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qpush-0.1.4 lib/qpush/web/apis/crons.rb