Skip to content

Commit

Permalink
Prefetch IndexedRegulationText and category parents
Browse files Browse the repository at this point in the history
  • Loading branch information
cgodwin1 committed Aug 26, 2024
1 parent 31ceccc commit 45b2399
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions solution/backend/content_search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)
from resources.utils import get_citation_filter, string_to_bool

from .models import ContentIndex
from .models import ContentIndex, IndexedRegulationText
from .serializers import ContentSearchSerializer


Expand Down Expand Up @@ -133,9 +133,12 @@ def list(self, request, *args, **kwargs):

# Prefetch all related data
query = query.prefetch_related(
Prefetch("reg_text", IndexedRegulationText.objects.all()),
Prefetch("resource", AbstractResource.objects.select_subclasses().prefetch_related(
Prefetch("cfr_citations", AbstractCitation.objects.select_subclasses()),
Prefetch("category", AbstractCategory.objects.select_subclasses()),
Prefetch("category", AbstractCategory.objects.select_subclasses().prefetch_related(
Prefetch("parent", AbstractCategory.objects.select_subclasses()),
)),
Prefetch("subjects", Subject.objects.all()),
)),
)
Expand Down

0 comments on commit 45b2399

Please sign in to comment.