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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user