Force postgresql setseed value in correct range
This commit partially backports commit AyuntamientoMadrid@f038399 by taking only the parts affecting code already in CONSUL's main repository.
This commit is contained in:
@@ -110,8 +110,13 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
end
|
||||
|
||||
def set_random_seed
|
||||
seed = Float(params[:random_seed] || session[:random_seed] || (rand(99) / 100.0)) rescue 0
|
||||
seed = begin
|
||||
Float(params[:random_seed] || session[:random_seed] || (rand(99) / 100.0))
|
||||
rescue
|
||||
0
|
||||
end
|
||||
session[:random_seed], params[:random_seed] = seed
|
||||
seed = (-1..1).cover?(seed) ? seed : 1
|
||||
::Legislation::Proposal.connection.execute "select setseed(#{seed})"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user