Skip to content

Instantly share code, notes, and snippets.

@ChasManRors
Created October 18, 2018 21:39
Show Gist options
  • Save ChasManRors/10bdbf49e91e07a841e68cfbe48f79e6 to your computer and use it in GitHub Desktop.
Save ChasManRors/10bdbf49e91e07a841e68cfbe48f79e6 to your computer and use it in GitHub Desktop.
batch_idx is increasing by batch_size. In this example 250
Count in the number of locations in this case 5440
Eventually batch_idx will be equal to of less then by < 250 (in_groups_of(batch_size, false)) RE: the false here
I have no idea how this reached 101. Empirically seems like this code would not do it.
num = 0
count = Location.count
(0..count).step(250) do |index|
num += 1
puts "#{num}) percent = #{(count > 0 ? index.to_f/count.to_f : 0)}"
end
1) percent = 0.0
2) percent = 0.04595588235294118
3) percent = 0.09191176470588236
4) percent = 0.13786764705882354
5) percent = 0.18382352941176472
6) percent = 0.22977941176470587
7) percent = 0.2757352941176471
8) percent = 0.32169117647058826
9) percent = 0.36764705882352944
10) percent = 0.41360294117647056
11) percent = 0.45955882352941174
12) percent = 0.5055147058823529
13) percent = 0.5514705882352942
14) percent = 0.5974264705882353
15) percent = 0.6433823529411765
16) percent = 0.6893382352941176
17) percent = 0.7352941176470589
18) percent = 0.78125
19) percent = 0.8272058823529411
20) percent = 0.8731617647058824
21) percent = 0.9191176470588235
22) percent = 0.9650735294117647
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment