From 53b5f01eb82b7e8b15f82d4dc5fb524579f41c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20Zar=C4=99bski?= Date: Fri, 23 May 2025 11:08:26 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20pagination=20entry=20c?= =?UTF-8?q?ount=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses a bug whereby if the count requested was greater than the pagination limit, rather than using the limit the user count was still passed meaning duplication of entries --- simvue/api/request.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/simvue/api/request.py b/simvue/api/request.py index 2ae11a8d..f4707850 100644 --- a/simvue/api/request.py +++ b/simvue/api/request.py @@ -303,12 +303,18 @@ def get_paginated( server response """ _offset: int = offset or 0 + + # Restrict the number of entries retrieved to be paginated, + # if the count requested is below page limit use this value + # else if undefined or greater than the page limit use the limit + _request_count: int = min(count or MAX_ENTRIES_PER_PAGE, MAX_ENTRIES_PER_PAGE) + while ( _response := get( url=url, headers=headers, params=(params or {}) - | {"count": count or MAX_ENTRIES_PER_PAGE, "start": _offset}, + | {"count": _request_count, "start": _offset}, timeout=timeout, json=json, ) From 13d05296243d5d35bff9c099044a94ae3256fd0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20Zar=C4=99bski?= Date: Fri, 23 May 2025 11:18:10 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=A8=20Run=20ruff=20formatting=20on?= =?UTF-8?q?=20request.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simvue/api/request.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/simvue/api/request.py b/simvue/api/request.py index f4707850..7f5496b1 100644 --- a/simvue/api/request.py +++ b/simvue/api/request.py @@ -313,8 +313,7 @@ def get_paginated( _response := get( url=url, headers=headers, - params=(params or {}) - | {"count": _request_count, "start": _offset}, + params=(params or {}) | {"count": _request_count, "start": _offset}, timeout=timeout, json=json, )