add a singleton value to allow multi-grouping only in rows or columns

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1788 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
t.felgentreff 14 years ago
parent 81e69d23ac
commit d93df84477
  1. 3
      app/controllers/cost_reports_controller.rb
  2. 1
      app/helpers/reporting_helper.rb
  3. 1
      app/models/cost_query/group_by.rb
  4. 5
      app/models/cost_query/group_by/singleton_value.rb
  5. 1
      app/models/cost_query/query_utils.rb
  6. 3
      app/models/cost_query/sql_statement.rb

@ -13,6 +13,9 @@ class CostReportsController < ApplicationController
elsif @query.depth_of(:column) + @query.depth_of(:row) == 1 elsif @query.depth_of(:column) + @query.depth_of(:row) == 1
@table_partial = "simple_cost_report_table" @table_partial = "simple_cost_report_table"
else else
if @query.depth_of(:column) == 0 || @query.depth_of(:row) == 0
@query.depth_of(:column) == 0 ? @query.column(:singleton_value) : @query.row(:singleton_value)
end
@table_partial = "cost_report_table" @table_partial = "cost_report_table"
end end
respond_to do |format| respond_to do |format|

@ -84,6 +84,7 @@ module ReportingHelper
when :week then "#{l(:label_week)} #%s" % value.to_i.modulo(100) when :week then "#{l(:label_week)} #%s" % value.to_i.modulo(100)
when :priority_id then IssuePriority.find(value.to_i).name when :priority_id then IssuePriority.find(value.to_i).name
when :fixed_version_id then Version.find(value.to_i).name when :fixed_version_id then Version.find(value.to_i).name
when :singleton_value then ""
else value.to_s else value.to_s
end end
end end

@ -11,6 +11,7 @@ module CostQuery::GroupBy
CostQuery::GroupBy::PriorityId, CostQuery::GroupBy::PriorityId,
CostQuery::GroupBy::ProjectId, CostQuery::GroupBy::ProjectId,
CostQuery::GroupBy::SpentOn, CostQuery::GroupBy::SpentOn,
CostQuery::GroupBy::SingletonValue,
CostQuery::GroupBy::Tmonth, CostQuery::GroupBy::Tmonth,
CostQuery::GroupBy::TrackerId, CostQuery::GroupBy::TrackerId,
#CostQuery::GroupBy::Tweek, #CostQuery::GroupBy::Tweek,

@ -0,0 +1,5 @@
module CostQuery::GroupBy
class SingletonValue < Base
dont_display!
end
end

@ -182,6 +182,7 @@ module CostQuery::QueryUtils
when "week" then value.to_i.divmod(100) when "week" then value.to_i.divmod(100)
when /_(on|at)$/ then value ? Time.parse(value) : Time.at(0) when /_(on|at)$/ then value ? Time.parse(value) : Time.at(0)
when /^custom_field/ then value.to_s when /^custom_field/ then value.to_s
when "singleton_value" then value.to_i
else fail "add mapping for #{key}" else fail "add mapping for #{key}"
end end
end end

@ -77,7 +77,8 @@ class CostQuery::SqlStatement
query.select({ query.select({
:count => 1, :id => [model, :id], :display_costs => 1, :count => 1, :id => [model, :id], :display_costs => 1,
:real_costs => switch("#{table}.overridden_costs IS NULL" => [model, :costs], :else => [model, :overridden_costs]), :real_costs => switch("#{table}.overridden_costs IS NULL" => [model, :costs], :else => [model, :overridden_costs]),
:week => iso_year_week(:spent_on, model) :week => iso_year_week(:spent_on, model),
:singleton_value => 1
}) })
#FIXME: build this subquery from a sql_statement #FIXME: build this subquery from a sql_statement
query.from "(SELECT *, #{typed :text, model.model_name} AS type FROM #{table}) AS #{table}" query.from "(SELECT *, #{typed :text, model.model_name} AS type FROM #{table}) AS #{table}"

Loading…
Cancel
Save