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

eager loading on versions/available_projects as well

ulfertsfc357b92ea07
diff --git a/lib/api/v3/projects/project_representer.rb b/lib/api/v3/projects/project_representer.rb
index e4a4c680e8a..a505eb18b0a 100644
--- a/lib/api/v3/projects/project_representer.rb
+++ b/lib/api/v3/projects/project_representer.rb
@@ -220,6 +220,7 @@ module API
end
self.to_eager_load = [:status,
+ :enabled_modules,
custom_values: :custom_field]
self.checked_permissions = [:add_work_packages]
diff --git a/lib/api/v3/projects/projects_api.rb b/lib/api/v3/projects/projects_api.rb
index 3221c220fda..6193c5d3a57 100644
--- a/lib/api/v3/projects/projects_api.rb
+++ b/lib/api/v3/projects/projects_api.rb
@@ -32,7 +32,11 @@ module API
class ProjectsAPI < ::API::OpenProjectAPI
resources :projects do
get &::API::V3::Utilities::Endpoints::Index.new(model: Project,
- scope: -> { Project.visible(User.current).includes(:enabled_modules).includes(ProjectRepresenter.to_eager_load) })
+ scope: -> {
+ Project
+ .visible(User.current)
+ .includes(ProjectRepresenter.to_eager_load)
+ })
.mount
post &::API::V3::Utilities::Endpoints::Create.new(model: Project)
diff --git a/lib/api/v3/versions/available_projects_api.rb b/lib/api/v3/versions/available_projects_api.rb
index 8f8ea3a44d4..db4e154b5c0 100644
--- a/lib/api/v3/versions/available_projects_api.rb
+++ b/lib/api/v3/versions/available_projects_api.rb
@@ -36,7 +36,11 @@ module API
resources :available_projects do
get &::API::V3::Utilities::Endpoints::Index.new(model: Project,
- scope: -> { Project.allowed_to(User.current, :manage_versions) })
+ scope: -> {
+ Project
+ .allowed_to(User.current, :manage_versions)
+ .includes(::API::V3::Projects::ProjectRepresenter.to_eager_load)
+ })
.mount
end
end