Skip to content

Commit

Permalink
Merge pull request #1853 from ResearchHub/unified-doc-fundraise-optim…
Browse files Browse the repository at this point in the history
…ization

Avoid individual subqueries in unified document
  • Loading branch information
gzurowski authored Sep 17, 2024
2 parents dfa3ddd + 19861f8 commit a2e01f1
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,11 @@ def test_get_unified_documents(self, request):
def get_unified_documents(self, request):
is_anonymous = request.user.is_anonymous
query_params = request.query_params
subscribed_hubs = query_params.get("subscribed_hubs", "false")
subscribed_hubs = query_params.get("subscribed_hubs", "false").lower() == "true"
filtering = query_params.get("ordering", HOT)
time_scope = query_params.get("time", "today")

if subscribed_hubs == "true" and not is_anonymous:
if subscribed_hubs and not is_anonymous:
return self._get_subscribed_unified_documents(request)

document_request_type = query_params.get("type", "all")
Expand All @@ -708,7 +708,7 @@ def get_unified_documents(self, request):
date_ranges=[time_scope],
)

documents = self.get_filtered_queryset()
documents = self.get_filtered_queryset().prefetch_related("fundraises")
context = self._get_serializer_context()
context["hub_id"] = hub_id
page = self.paginate_queryset(documents)
Expand Down

0 comments on commit a2e01f1

Please sign in to comment.