From 9935082b7e6b4eb900ee6830042d0a80543f3a7d Mon Sep 17 00:00:00 2001 From: tobi Date: Tue, 30 Dec 2008 16:39:10 -0700 Subject: [PATCH] Use sort_by{rand} instead of sort{rand} for randomization as sort{rand} is of consistent outcome. Thanks Alex Ostleitner. --- lib/delayed/job.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/delayed/job.rb b/lib/delayed/job.rb index f826efcc0..b05100e51 100644 --- a/lib/delayed/job.rb +++ b/lib/delayed/job.rb @@ -1,4 +1,3 @@ - module Delayed class DeserializationError < StandardError @@ -113,7 +112,7 @@ def self.find_available(limit = 5, max_run_time = MAX_RUN_TIME) find(:all, :conditions => conditions, :order => NextTaskOrder, :limit => limit) end - records.sort { rand() } + records.sort_by { rand() } end # Get the payload of the next job we can get an exclusive lock on.