Simplified QuantityInput#lastBefore
This commit is contained in:
parent
580e9156e6
commit
a8d31f26d2
@ -59,8 +59,12 @@ class Formula < ActiveRecord::Base
|
|||||||
vindex = 0
|
vindex = 0
|
||||||
lastval = nil
|
lastval = nil
|
||||||
timepoints.each_with_index.sort_by { |t, i| t || Time.current }.map do |time, index|
|
timepoints.each_with_index.sort_by { |t, i| t || Time.current }.map do |time, index|
|
||||||
#lastval = values[vindex++].last while values[vindex].first <= time
|
while vindex < values.length && values[vindex].first <= time
|
||||||
vindex += values[vindex..-1].find_all { |vtime, v| lastval = v; vtime <= time }.length
|
lastval = values[vindex].last
|
||||||
|
vindex += 1
|
||||||
|
end
|
||||||
|
#vindex += values[vindex..-1].find_all { |vtime, v| lastval = v; vtime <= time }
|
||||||
|
#.length
|
||||||
[lastval, index]
|
[lastval, index]
|
||||||
end.sort_by(&:last).transpose.first
|
end.sort_by(&:last).transpose.first
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user