|
@@ -37,12 +37,15 @@ class HelloWorldController < ApplicationController
|
|
|
queries = 1 if queries < 1
|
|
|
queries = 500 if queries > 500
|
|
|
|
|
|
- numbers = (1..10000).to_a.sample(queries)
|
|
|
+ numbers = (1..10000).to_a.sample(queries).sort
|
|
|
worlds = numbers.map do |id|
|
|
|
# get a random row from the database, which we know has 10000
|
|
|
# rows with ids 1 - 10000
|
|
|
world = World.select(:id, :randomNumber).find(id)
|
|
|
- world.update_attribute(:randomNumber, Random.rand(1..10000))
|
|
|
+ begin
|
|
|
+ rn = Random.rand(1..10000)
|
|
|
+ end while rn == world.randomNumber
|
|
|
+ world.update_attribute(:randomNumber, rn)
|
|
|
world
|
|
|
end
|
|
|
|