|
|
|
@ -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 |
|
|
|
|