Skip to content

Commit

Permalink
Eager load nodes children and their pages
Browse files Browse the repository at this point in the history
Still not ideal since aweseom_nested_set does not allow to eager load
all descendents, but this reduces the db queries to the number of levels the
menu has.
  • Loading branch information
tvdeyen committed Jan 22, 2021
1 parent cc53887 commit c8da141
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/alchemy/json_api/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def page_scope
def page_scope_with_includes
base_page_scope.
with_language(Language.current).
preload(language: { nodes: [:parent, :page] }, all_elements: { contents: { essence: :ingredient_association } })
preload(language: { nodes: [{ parent: :page}, :page, { children: :page }] }, all_elements: { contents: { essence: :ingredient_association } })
end

def base_page_scope
Expand Down

0 comments on commit c8da141

Please sign in to comment.