Skip to content

Commit

Permalink
refactor pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardKoschicek committed Dec 9, 2024
1 parent 04480c0 commit 5fbaea1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions openatlas/api/endpoints/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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':
Expand All @@ -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())
Expand Down

0 comments on commit 5fbaea1

Please sign in to comment.