Skip to content

Commit

Permalink
Fix for count
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Sánchez committed Feb 16, 2021
1 parent 1629d34 commit 6addc34
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions agave/blueprints/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@ def query():
if self.user_id_filter_required():
query_params.user_id = self.current_user_id
filters = cls.get_query_filter(query_params)
if hasattr(cls, 'query'):
return cls.query(_all(query_params, filters))
if query_params.count:
return _count(filters)
return _all(query_params, filters)
result = _count(filters)
elif hasattr(cls, 'query'):
result = cls.query(_all(query_params, filters))
else:
result = _all(query_params, filters)
return result

def _count(filters: Q):
count = cls.model.objects.filter(filters).count()
Expand Down

0 comments on commit 6addc34

Please sign in to comment.