lib/sidekiq-status/storage.rb in sidekiq-status-0.5.4 vs lib/sidekiq-status/storage.rb in sidekiq-status-0.6.0
- old
+ new
@@ -56,11 +56,11 @@
# @param [String] id job id
# @param [String] Symbol field fetched field name
# @return [String] Redis operation status code
def read_field_for_id(id, field)
Sidekiq.redis do |conn|
- conn.hmget(key(id), field)[0]
+ conn.hget(key(id), field)
end
end
# Gets the whole status hash from the job status
# @param [String] id job id
@@ -89,11 +89,10 @@
# @param [String] id job id
def scan_scheduled_jobs_for_jid(scheduled_jobs, job_id)
# A Little skecthy, I know, but the structure of these internal JSON
# is predefined in such a way where this will not catch unintentional elements,
# and this is notably faster than performing JSON.parse() for every listing:
- scheduled_jobs.each { |job_listing| (return job_listing) if job_listing.include?("\"jid\":\"#{job_id}") }
- nil
+ scheduled_jobs.select { |job_listing| job_listing.match(/\"jid\":\"#{job_id}\"/) }[0]
end
# Yields redis connection. Uses redis pool if available.
# @param [ConnectionPool] redis_pool optional redis connection pool
def redis_connection(redis_pool=nil)