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

actually provide all relevant custom fields for performance hack

ulfertse37974dbed76
diff --git a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb
index fa5e3e68f43..0f6935096cb 100644
--- a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb
+++ b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb
@@ -304,7 +304,6 @@ module API
def form_config_attribute_representation(group)
cache_keys = ['wp_schema_attribute_group',
group.key,
- group.attributes,
I18n.locale,
represented.project,
represented.type,
diff --git a/lib/api/v3/work_packages/work_package_collection_representer.rb b/lib/api/v3/work_packages/work_package_collection_representer.rb
index 8ff74d707f1..5b951309b22 100644
--- a/lib/api/v3/work_packages/work_package_collection_representer.rb
+++ b/lib/api/v3/work_packages/work_package_collection_representer.rb
@@ -175,7 +175,7 @@ module API
schemas = schema_pairs.map do |project, type, available_custom_fields|
# This hack preloads the custom fields for a project so that they do not have to be
# loaded again later on
- project.instance_variable_set(:'@all_work_package_custom_fields', available_custom_fields)
+ project.instance_variable_set(:'@all_work_package_custom_fields', all_cfs_of_project[project.id])
Schema::TypedWorkPackageSchema.new(project: project, type: type, custom_fields: available_custom_fields)
end
@@ -199,6 +199,13 @@ module API
.uniq
end
+ def all_cfs_of_project
+ @all_cfs_of_project ||= represented
+ .group_by(&:project_id)
+ .map { |id, wps| [id, wps.map(&:available_custom_fields).flatten.uniq] }
+ .to_h
+ end
+
def paged_models(models)
models.page(@page).per_page(@per_page).pluck(:id)
end