Skip to content

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

reuse getter method

ulferts2311a9472dba
diff --git a/modules/reporting/app/models/cost_query/custom_field_mixin.rb b/modules/reporting/app/models/cost_query/custom_field_mixin.rb
index 117f37852cf..4b8c57e3f0e 100644
--- a/modules/reporting/app/models/cost_query/custom_field_mixin.rb
+++ b/modules/reporting/app/models/cost_query/custom_field_mixin.rb
@@ -109,9 +109,6 @@ module CostQuery::CustomFieldMixin
end
def list_join_table(field)
- cast_as = SQL_TYPES[field.field_format]
- cf_name = "custom_field#{field.id}"
-
custom_values_table = CustomValue.table_name
custom_options_table = CustomOption.table_name
@@ -119,10 +116,10 @@ module CostQuery::CustomFieldMixin
# Because of this, we do not cast the cv.value but rather the co.id
<<-SQL
- -- BEGIN Custom Field Join: #{cf_name}
+ -- BEGIN Custom Field Join: #{db_field}
LEFT OUTER JOIN (
SELECT
- co.id AS #{cf_name},
+ co.id AS #{db_field},
co.value,
cv.customized_type,
cv.custom_field_id,
@@ -130,12 +127,12 @@ module CostQuery::CustomFieldMixin
FROM #{custom_values_table} cv
INNER JOIN #{custom_options_table} co
ON cv.custom_field_id = co.custom_field_id AND cv.value = co.id::VARCHAR
- ) AS #{cf_name}
- ON #{cf_name}.customized_type = 'WorkPackage'
+ ) AS #{db_field}
+ ON #{db_field}.customized_type = 'WorkPackage'
- AND #{cf_name}.custom_field_id = #{field.id}
- AND #{cf_name}.customized_id = entries.work_package_id
- -- END Custom Field Join: #{cf_name}
+ AND #{db_field}.custom_field_id = #{field.id}
+ AND #{db_field}.customized_id = entries.work_package_id
+ -- END Custom Field Join: #{db_field}
SQL
end