Make legislation proposals random seed more robust

Using a number with only two decimals means the seed is going to be the
same 1% of the time. Using ruby's default value for random numbers makes
it almost impossible to generate the same seed twice.

Using `rand` also simplifies the code, and it's what we use in the
budget investments controller.
This commit is contained in:
Javi Martín
2018-10-01 20:54:03 +02:00
parent 07c22d289c
commit 1b46ba9ee6

View File

@@ -117,7 +117,7 @@ class Legislation::ProcessesController < Legislation::BaseController
end
def set_random_seed
seed = (params[:random_seed] || session[:random_seed] || (rand(99) / 100.0)).to_f
seed = (params[:random_seed] || session[:random_seed] || rand).to_f
seed = (-1..1).cover?(seed) ? seed : 1
session[:random_seed] = seed