discourse/spec/fabricators/sidebar_section_link_fabricator.rb
Alan Guo Xiang Tan 8fec1a412b
PERF: Eager load linkables when loading custom sidebar sections (#20490)
Not eager loading was resulting in the N+1 queries problem when
serializing with the `CurrentUserSerializer` as
`CurrentUserSerializer#sidebar_sections` serializes the sections with
`SidebarSectionSerializer` which fetches all the `SidebarUrl` records
for each `SidebarSection` record.
2023-03-01 07:39:35 +08:00

15 lines
450 B
Ruby

# frozen_string_literal: true
Fabricator(:sidebar_section_link) { user }
Fabricator(:category_sidebar_section_link, from: :sidebar_section_link) do
linkable(fabricator: :category)
end
Fabricator(:tag_sidebar_section_link, from: :sidebar_section_link) { linkable(fabricator: :tag) }
Fabricator(:custom_sidebar_section_link, from: :sidebar_section_link) do
linkable(fabricator: :sidebar_url)
sidebar_section(fabricator: :sidebar_section)
end