提交 4513cc14 编写于 作者: E Emilio Tagua 提交者: Santiago Pastorino

Goodbye inject, hello map.

Signed-off-by: NSantiago Pastorino <santiago@wyeworks.com>
上级 569be76e
......@@ -225,13 +225,11 @@ def execute_grouped_calculation(operation, column_name) #:nodoc:
key_records = key_records.inject({}) { |hsh, r| hsh.merge(r.id => r) }
end
calculated_data.inject(ActiveSupport::OrderedHash.new) do |all, row|
key = type_cast_calculated_value(row[group_alias], group_column)
key = key_records[key] if associated
value = row[aggregate_alias]
all[key] = type_cast_calculated_value(value, column_for(column_name), operation)
all
end
ActiveSupport::OrderedHash[calculated_data.map do |row|
key = type_cast_calculated_value(row[group_alias], group_column)
key = key_records[key] if associated
[key, type_cast_calculated_value(row[aggregate_alias], column_for(column_name), operation)]
end]
end
# Converts the given keys to the value that the database adapter returns as
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册