Sha256: fb1bfc003cc51f715b594a82067fb7a8e2612298739b87174879584afaaa2868

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 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 = Web.redis 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.6 lib/qpush/web/apis/crons.rb