From 692d46a95f8f24bdd3135bc83a217452bb7f975f Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Mon, 24 Mar 2025 17:18:57 +0100 Subject: [PATCH 1/2] handle limit-offset in templates --- runtimes/eoapi/stac/eoapi/stac/client.py | 12 ------------ .../eoapi/stac/eoapi/stac/templates/collections.html | 10 +++++----- runtimes/eoapi/stac/eoapi/stac/templates/items.html | 8 ++++---- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/runtimes/eoapi/stac/eoapi/stac/client.py b/runtimes/eoapi/stac/eoapi/stac/client.py index 76b42f6..9f8af38 100644 --- a/runtimes/eoapi/stac/eoapi/stac/client.py +++ b/runtimes/eoapi/stac/eoapi/stac/client.py @@ -1,7 +1,6 @@ """eoapi-devseed: Custom pgstac client.""" import csv -import math import re from typing import ( Any, @@ -363,21 +362,11 @@ async def all_collections( ) if output_type == MimeTypes.html: - offset = int(request.query_params.get("offset") or 0) - limit = int(request.query_params.get("limit") or 10) - - current_page = 1 - if limit > 0: - current_page = math.ceil((offset + limit) / limit) - return create_html_response( request, collections, template_name="collections", title="Collections list", - current_page=current_page, - limit=limit, - offset=offset, ) return collections @@ -529,7 +518,6 @@ async def item_collection( item_collection, template_name="items", title=f"{collection_id} items", - limit=limit, ) elif output_type == MimeTypes.csv: diff --git a/runtimes/eoapi/stac/eoapi/stac/templates/collections.html b/runtimes/eoapi/stac/eoapi/stac/templates/collections.html index 080c5f4..c83cc6d 100644 --- a/runtimes/eoapi/stac/eoapi/stac/templates/collections.html +++ b/runtimes/eoapi/stac/eoapi/stac/templates/collections.html @@ -24,7 +24,7 @@

Collections

{% else %}
- Showing {{ offset + 1 }} - {{ offset + response.numberReturned }} of {{ response.numberMatched }} collections + Showing {{ template.params.get("offset", 0)|int + 1 }} - {{ template.params.get("offset", 0)|int + response.numberReturned }} of {{ response.numberMatched }} collections
@@ -43,10 +43,10 @@

Collections

diff --git a/runtimes/eoapi/stac/eoapi/stac/templates/items.html b/runtimes/eoapi/stac/eoapi/stac/templates/items.html index d2f4470..485e536 100644 --- a/runtimes/eoapi/stac/eoapi/stac/templates/items.html +++ b/runtimes/eoapi/stac/eoapi/stac/templates/items.html @@ -36,10 +36,10 @@

{% if response.links|length > 0 %} From 17d88c40d2544f97ecccb5b1e7157d6b24977602 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Mon, 24 Mar 2025 17:39:20 +0100 Subject: [PATCH 2/2] add back missing url --- runtimes/eoapi/stac/eoapi/stac/templates/collections.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runtimes/eoapi/stac/eoapi/stac/templates/collections.html b/runtimes/eoapi/stac/eoapi/stac/templates/collections.html index c83cc6d..f3254c1 100644 --- a/runtimes/eoapi/stac/eoapi/stac/templates/collections.html +++ b/runtimes/eoapi/stac/eoapi/stac/templates/collections.html @@ -1,5 +1,11 @@ {% extends "base.html" %} +{% if params %} + {% set urlq = url + '?' + params + '&' %} + {% else %} + {% set urlq = url + '?' %} +{% endif %} + {% block content %}