From 5fbaea13529cf0416438bc05ccd16689fff38539 Mon Sep 17 00:00:00 2001 From: Bernhard Koschicek-Krombholz Date: Mon, 9 Dec 2024 16:52:09 +0100 Subject: [PATCH] refactor pagination --- openatlas/api/endpoints/endpoint.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openatlas/api/endpoints/endpoint.py b/openatlas/api/endpoints/endpoint.py index 41ba8ceec..3d2bf9dd8 100644 --- a/openatlas/api/endpoints/endpoint.py +++ b/openatlas/api/endpoints/endpoint.py @@ -17,7 +17,8 @@ from openatlas.api.resources.resolve_endpoints import ( download, parse_loud_context) from openatlas.api.resources.templates import ( - geojson_collection_template, linked_places_template, loud_template) + geojson_collection_template, linked_places_template, loud_template, + ) from openatlas.api.resources.util import ( get_linked_entities_api, get_location_link, remove_duplicate_entities) from openatlas.models.entity import Entity, Link @@ -73,6 +74,8 @@ def resolve_entities(self) -> Response | dict[str, Any]: self.remove_duplicate_entities() self.sort_entities() self.get_pagination() + if self.parser.count == 'true': + return jsonify(self.pagination['count']) self.reduce_entities_list() if self.parser.export == 'csv': @@ -90,8 +93,7 @@ def resolve_entities(self) -> Response | dict[str, Any]: return Response( self.parser.rdf_output(result['results']), mimetype=app.config['RDF_FORMATS'][self.parser.format]) - if self.parser.count == 'true': - return jsonify(result['pagination']['entities']) + if self.parser.download == 'true': return download(result, self.parser.get_entities_template()) return marshal(result, self.parser.get_entities_template())