|
@@ -37,15 +37,14 @@ class HelloWorldController < ApplicationController
|
|
|
queries = 1 if queries < 1
|
|
|
queries = 500 if queries > 500
|
|
|
|
|
|
- numbers = (1..10000).to_a.sample(queries).sort
|
|
|
- worlds = numbers.map do |id|
|
|
|
+ worlds = queries.times.map{Random.rand(1..10_000)}.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)
|
|
|
begin
|
|
|
rn = Random.rand(1..10000)
|
|
|
end while rn == world.randomNumber
|
|
|
- world.update_attribute(:randomNumber, rn)
|
|
|
+ world.update_column(:randomNumber, rn)
|
|
|
world
|
|
|
end
|
|
|
|