From 6addc349e0f38d177bfe1aa48086543705b931d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20S=C3=A1nchez?= Date: Tue, 9 Feb 2021 00:43:09 -0600 Subject: [PATCH] Fix for count --- agave/blueprints/rest_api.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/agave/blueprints/rest_api.py b/agave/blueprints/rest_api.py index 2068673a..99499876 100644 --- a/agave/blueprints/rest_api.py +++ b/agave/blueprints/rest_api.py @@ -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()