Skip to content

Commit

Permalink
Merge pull request #13617 from opf/fix/reenable_specifying_eager_load…
Browse files Browse the repository at this point in the history
…ing_in_endpoints

Fix/reenable specifying eager loading in endpoints
  • Loading branch information
aaron-contreras committed Sep 4, 2023
2 parents 0b2d53e + e049148 commit d3b4ec0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/api/v3/memberships/membership_representer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ class MembershipRepresenter < ::API::Decorators::Single
date_time_property :created_at
date_time_property :updated_at

self.to_eager_load = %i[principal
project
roles]
self.to_eager_load = [:principal,
{ project: :enabled_modules },
{ member_roles: :role }]

def _type
'Membership'
Expand Down
5 changes: 1 addition & 4 deletions lib/api/v3/projects/project_representer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,7 @@ def _type
'Project'
end

self.to_eager_load = [:status,
:parent,
:enabled_modules,
{ custom_values: :custom_field }]
self.to_eager_load = [:enabled_modules]

self.checked_permissions = [:add_work_packages]
end
Expand Down
4 changes: 3 additions & 1 deletion lib/api/v3/utilities/endpoints/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def apply_scope_constraint(constraint, result_scope)
if constraint.is_a?(Class)
result_scope
else
result_scope.where id: constraint.select(:id)
result_scope
.includes(constraint.includes_values)
.where id: constraint.select(:id)
end
end
end
Expand Down

0 comments on commit d3b4ec0

Please sign in to comment.