recent changes

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1131 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
rkh 15 years ago
parent 582aeea41e
commit 9018c50673
  1. 20
      app/models/cost_query/walker.rb

@ -4,8 +4,8 @@ class CostQuery::Walker
def initialize(query)
@query = query
end
end
##
# @return [CostQuery::Result::Base] Result tree with row group bys at the top
# @see CostQuery::Chainable#result
@ -44,7 +44,21 @@ class CostQuery::Walker
columns + rows
end
def walk
raise NotImplementedError, "done"
##
# @example
# query.walk(:column_first) do |current, subgregation|
# if subgregation.nil?
# ["<td>#{current.count}</td>"]
# elsif current.type == :column
# subgregation.first.unshift "<td rowspan='#{subgregation.size}'>#{current.group_fields}</td>"
# else
# subgregation.flatten
# end
# end
def walk(result = nil, &block)
result ||= row_first
result = send result if result.is_a? Symbol
return block.call(result, nil) unless result.has_children?
block.call result, result.map { |r| walk(r, &block) }
end
end

Loading…
Cancel
Save