OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
inline set_xxx! methods in CustomFieldSelect
Ivan Kuchin82a7e2ef0602
diff --git a/app/models/queries/work_packages/selects/custom_field_select.rb b/app/models/queries/work_packages/selects/custom_field_select.rbindex 21a0f0c730b..38e429839ad 100644--- a/app/models/queries/work_packages/selects/custom_field_select.rb+++ b/app/models/queries/work_packages/selects/custom_field_select.rb@@ -32,10 +32,10 @@ class Queries::WorkPackages::Selects::CustomFieldSelect < Queries::WorkPackages:@cf = custom_field- set_name!- set_sortable!- set_groupable!- set_summable!+ @name = custom_field.column_name.to_sym+ @sortable = custom_field.order_statements || false+ @groupable = groupable_custom_field?(custom_field) ? custom_field.group_by_statement || false : false+ @summable = summable_statementenddef groupable_custom_field?(custom_field)@@ -68,31 +68,6 @@ class Queries::WorkPackages::Selects::CustomFieldSelect < Queries::WorkPackages:private- def set_name!- @name = custom_field.column_name.to_sym- end-- def set_sortable!- @sortable = custom_field.order_statements || false- end-- def set_groupable!- @groupable = groupable_custom_field?(custom_field) ? custom_field.group_by_statement || false : false- end-- def set_summable!- @summable = if %w(float int).include?(custom_field.field_format)- select = summable_select_statement-- ->(query, grouped) {- Queries::WorkPackages::Selects::WorkPackageSelect- .scoped_column_sum(summable_scope(query), select, grouped && query.group_by_statement)- }- else- false- end- end-def summable_scope(query)WorkPackage.where(id: query.results.work_packages)@@ -109,4 +84,17 @@ class Queries::WorkPackages::Selects::CustomFieldSelect < Queries::WorkPackages:"COALESCE(ROUND(SUM(value::NUMERIC), 2)::FLOAT, 0.0) #{name}"endend++ def summable_statement+ if %w[float int].include?(custom_field.field_format)+ select = summable_select_statement++ ->(query, grouped) {+ Queries::WorkPackages::Selects::WorkPackageSelect+ .scoped_column_sum(summable_scope(query), select, grouped && query.group_by_statement)+ }+ else+ false+ end+ endend