Skip to content

Commit

Permalink
Merge pull request readthedocs#4322 from italia/fasterqsfiltering
Browse files Browse the repository at this point in the history
Do less work in querysets
  • Loading branch information
ericholscher authored Jul 3, 2018
2 parents f895af5 + 8d63db2 commit ab3b567
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions readthedocs/builds/querysets.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _add_user_repos(self, queryset, user=None):
return self.all().distinct()
if user.is_authenticated():
user_queryset = get_objects_for_user(user, 'builds.view_version')
pks = [p.pk for p in user_queryset]
pks = user_queryset.values_list('pk', flat=True)
queryset = self.filter(version__pk__in=pks) | queryset
return queryset.distinct()

Expand Down Expand Up @@ -118,7 +118,7 @@ def _add_user_repos(self, queryset, user=None):
return self.all().distinct()
if user.is_authenticated():
user_queryset = get_objects_for_user(user, 'builds.view_version')
pks = [p.pk for p in user_queryset]
pks = user_queryset.values_list('pk', flat=True)
queryset = self.filter(
build__version__pk__in=pks) | queryset
return queryset.distinct()
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/projects/querysets.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _add_user_repos(self, queryset, user=None):
if user.is_authenticated():
# Add in possible user-specific views
project_qs = get_objects_for_user(user, 'projects.view_project')
pks = [p.pk for p in project_qs]
pks = project_qs.values_list('pk', flat=True)
kwargs = {'%s__pk__in' % self.project_field: pks}
queryset = self.filter(**kwargs) | queryset
return queryset.distinct()
Expand Down

0 comments on commit ab3b567

Please sign in to comment.