[Issues Board Sorting] Wrong relative position calculation
Only exists in master (1 day)
We calculate relative position based on a random number between two terminating positions. This algorithm is not going to work because maximum value will be gotten pretty fast: 16-25 iterations(for 4 bytes integer) If we used float (8 bytes is default for ruby and postgresql) that would be 40-45 iterations. So it's not a matter of size, the algorithm is just wrong.
To prove that I wrote a little script:
max = 2147483647
min = 0
resulted_value = nil
20000.times do |i|
resulted_value ||= min
resulted_value = rand(resulted_value..max)
puts resulted_value
if resulted_value == max
raise "got max value after #{i} iterations"
end
end
puts "Result: #{resulted_value}"
/cc @DouweM @smcgivern
Edited by 🤖 GitLab Bot 🤖