Skip to content

Commit

Permalink
fix: aggregate compacts before calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
jozefvaclavik committed May 8, 2024
1 parent 2b46567 commit e06ed26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/trifle/stats/aggregator/max.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def aggregate(series:, path:, slices: 1)
end

def sliced(result:, slices:)
result[(result.count - (result.count / slices * slices))..].each_slice(result.count / slices).map(&:max)
result[(result.count - (result.count / slices * slices))..].each_slice(result.count / slices).map do |slice|
slice.compact.max
end
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/trifle/stats/aggregator/min.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def aggregate(series:, path:, slices: 1)
end

def sliced(result:, slices:)
result[(result.count - (result.count / slices * slices))..].each_slice(result.count / slices).map(&:min)
result[(result.count - (result.count / slices * slices))..].each_slice(result.count / slices).map do |slice|
slice.compact.min
end
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/trifle/stats/aggregator/sum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def aggregate(series:, path:, slices: 1)
end

def sliced(result:, slices:)
result[(result.count - (result.count / slices * slices))..].each_slice(result.count / slices).map(&:sum)
result[(result.count - (result.count / slices * slices))..].each_slice(result.count / slices).map do |slice|
slice.compact.sum
end
end
end
end
Expand Down

0 comments on commit e06ed26

Please sign in to comment.