Skip to content

Commit

Permalink
Merge pull request #83 from ZuluPro/pagination
Browse files Browse the repository at this point in the history
Count in pagination is so slow
  • Loading branch information
eamigo86 authored Nov 22, 2018
2 parents 7c0a542 + e844cb3 commit 00eeb41
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions graphene_django_extras/paginations/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def to_graphql_fields(self):
}

def paginate_queryset(self, qs, **kwargs):
count = _get_count(qs)
limit = _nonzero_int(
kwargs.get(self.limit_query_param, None),
strict=True,
Expand All @@ -96,13 +95,7 @@ def paginate_queryset(self, qs, **kwargs):
else:
qs = qs.order_by(order)

if limit < 0:
offset = kwargs.get(self.offset_query_param, count) + limit
else:
offset = kwargs.get(self.offset_query_param, 0)

if count == 0 or offset > count or offset < 0:
return []
offset = kwargs.get(self.offset_query_param, 0)

return qs[offset:offset + fabs(limit)]

Expand Down

0 comments on commit 00eeb41

Please sign in to comment.