fix grouping by cf while summing (#8881)

pull/8886/head
ulferts 4 years ago committed by GitHub
parent 5a6899b8e5
commit bf9bc70bb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      app/models/custom_field/order_statements.rb
  2. 2
      app/models/queries/work_packages/columns/custom_field_column.rb

@ -43,7 +43,7 @@ module CustomField::OrderStatements
if multi_value? if multi_value?
[select_custom_values_as_group] [select_custom_values_as_group]
else else
coalesce_select_custom_value_as_string [coalesce_select_custom_value_as_string]
end end
when 'int', 'float' when 'int', 'float'
# Make the database cast values into numeric # Make the database cast values into numeric
@ -73,12 +73,12 @@ module CustomField::OrderStatements
# Returns the grouping result # Returns the grouping result
# which differ for multi-value select fields, # which differ for multi-value select fields,
# because in this case we do want the primary CV values # because in this case we do want the primary CV values
def group_by_statements def group_by_statement
return order_statements unless field_format == 'list' return order_statements unless field_format == 'list'
if multi_value? if multi_value?
# We want to return the internal IDs in the case of grouping # We want to return the internal IDs in the case of grouping
[select_custom_values_as_group] select_custom_values_as_group
else else
coalesce_select_custom_value_as_string coalesce_select_custom_value_as_string
end end
@ -88,11 +88,9 @@ module CustomField::OrderStatements
def coalesce_select_custom_value_as_string def coalesce_select_custom_value_as_string
# COALESCE is here to make sure that blank and NULL values are sorted equally # COALESCE is here to make sure that blank and NULL values are sorted equally
[ <<-SQL
<<-SQL COALESCE(#{select_custom_value_as_string}, '')
COALESCE(#{select_custom_value_as_string}, '') SQL
SQL
]
end end
def select_custom_value_as_string def select_custom_value_as_string

@ -81,7 +81,7 @@ class Queries::WorkPackages::Columns::CustomFieldColumn < Queries::WorkPackages:
end end
def set_groupable! def set_groupable!
self.groupable = custom_field.group_by_statements if groupable_custom_field?(custom_field) self.groupable = custom_field.group_by_statement if groupable_custom_field?(custom_field)
self.groupable ||= false self.groupable ||= false
end end

Loading…
Cancel
Save