Merge pull request #3420 from consul/backport-fix_sort_by_random
Fix sort by random inconsistencies
This commit is contained in:
@@ -3,7 +3,7 @@ module Randomizable
|
|||||||
|
|
||||||
class_methods do
|
class_methods do
|
||||||
def sort_by_random(seed = rand(10_000_000))
|
def sort_by_random(seed = rand(10_000_000))
|
||||||
ids = pluck(:id).shuffle(random: Random.new(seed))
|
ids = order(:id).pluck(:id).shuffle(random: Random.new(seed))
|
||||||
|
|
||||||
return all if ids.empty?
|
return all if ids.empty?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user