Skip to content

Commit

Permalink
Optimise list identities endpoint (#170)
Browse files Browse the repository at this point in the history
* Optimise list identities endpoint

* Remove temporary logging
  • Loading branch information
matthewelwell authored Jul 7, 2021
1 parent afaedea commit f3d7fb0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions api/environments/identities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@ class IdentityViewSet(viewsets.ModelViewSet):
pagination_class = CustomPagination

def get_queryset(self):
environment = self.get_environment_from_request()
user_permitted_identities = self.request.user.get_permitted_identities()
queryset = user_permitted_identities.filter(
environment__api_key=environment.api_key
)
environment_api_key = self.kwargs["environment_api_key"]
queryset = Identity.objects.filter(environment__api_key=environment_api_key)

if self.request.query_params.get("q"):
queryset = queryset.filter(
identifier__icontains=self.request.query_params.get("q")
)
search_query = self.request.query_params.get("q")
if search_query:
queryset = queryset.filter(identifier__icontains=search_query)

return queryset

Expand Down

0 comments on commit f3d7fb0

Please sign in to comment.