Sha256: 8d1e4648d4ca08cd6648528168907a817c1f3b68533b47b126ff6f7a368b6471

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 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(Web.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.7 lib/qpush/web/apis/crons.rb