diff --git a/app/controllers/cost_reports_controller.rb b/app/controllers/cost_reports_controller.rb index 48298ce5ce..10c4cade94 100644 --- a/app/controllers/cost_reports_controller.rb +++ b/app/controllers/cost_reports_controller.rb @@ -13,6 +13,9 @@ class CostReportsController < ApplicationController elsif @query.depth_of(:column) + @query.depth_of(:row) == 1 @table_partial = "simple_cost_report_table" 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" end respond_to do |format| diff --git a/app/helpers/reporting_helper.rb b/app/helpers/reporting_helper.rb index 2ec0c1938c..899b3219e5 100644 --- a/app/helpers/reporting_helper.rb +++ b/app/helpers/reporting_helper.rb @@ -84,6 +84,7 @@ module ReportingHelper when :week then "#{l(:label_week)} #%s" % value.to_i.modulo(100) when :priority_id then IssuePriority.find(value.to_i).name when :fixed_version_id then Version.find(value.to_i).name + when :singleton_value then "" else value.to_s end end diff --git a/app/models/cost_query/group_by.rb b/app/models/cost_query/group_by.rb index da723a4df5..42b36c96e3 100644 --- a/app/models/cost_query/group_by.rb +++ b/app/models/cost_query/group_by.rb @@ -11,6 +11,7 @@ module CostQuery::GroupBy CostQuery::GroupBy::PriorityId, CostQuery::GroupBy::ProjectId, CostQuery::GroupBy::SpentOn, + CostQuery::GroupBy::SingletonValue, CostQuery::GroupBy::Tmonth, CostQuery::GroupBy::TrackerId, #CostQuery::GroupBy::Tweek, diff --git a/app/models/cost_query/group_by/singleton_value.rb b/app/models/cost_query/group_by/singleton_value.rb new file mode 100644 index 0000000000..eeb3d7c800 --- /dev/null +++ b/app/models/cost_query/group_by/singleton_value.rb @@ -0,0 +1,5 @@ +module CostQuery::GroupBy + class SingletonValue < Base + dont_display! + end +end diff --git a/app/models/cost_query/query_utils.rb b/app/models/cost_query/query_utils.rb index bd2ea0105f..01cb4c0f82 100644 --- a/app/models/cost_query/query_utils.rb +++ b/app/models/cost_query/query_utils.rb @@ -182,6 +182,7 @@ module CostQuery::QueryUtils when "week" then value.to_i.divmod(100) when /_(on|at)$/ then value ? Time.parse(value) : Time.at(0) when /^custom_field/ then value.to_s + when "singleton_value" then value.to_i else fail "add mapping for #{key}" end end diff --git a/app/models/cost_query/sql_statement.rb b/app/models/cost_query/sql_statement.rb index 1bcc0cf6b8..e4ddf65efc 100644 --- a/app/models/cost_query/sql_statement.rb +++ b/app/models/cost_query/sql_statement.rb @@ -77,7 +77,8 @@ class CostQuery::SqlStatement query.select({ :count => 1, :id => [model, :id], :display_costs => 1, :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 query.from "(SELECT *, #{typed :text, model.model_name} AS type FROM #{table}) AS #{table}"