Skip to content

Instantly share code, notes, and snippets.

@mib32
Created June 3, 2016 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mib32/cfbbeadd6e08a66cc03e47a5b495ca87 to your computer and use it in GitHub Desktop.
Save mib32/cfbbeadd6e08a66cc03e47a5b495ca87 to your computer and use it in GitHub Desktop.
function of double array calculation
stats_source.clicks_statistic_by(start_date..end_date, :device).tap {|arr| arr.map{|row| row[:max] = arr.max{|a, b| a[:clicks_amount] <=> b[:clicks_amount]}[:clicks_amount]}}.map{|row| row[:clicks_percentage] = 100 * row[:clicks_amount] / row[:max]; row}.each do |row|
print row
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment