From d04b5e8dc4743890954504c265f0f840f9e97aa4 Mon Sep 17 00:00:00 2001 From: C1-BA-B1-F3 Date: Sat, 3 Oct 2026 11:31:23 +0800 Subject: [PATCH] fix(process manager): apply limit and offset in get_jobs PostgreSQL and MongoDB managers ignored the limit and offset parameters, returning all jobs regardless of the query string. Apply offset before limit in both backends, matching the existing TinyDB behaviour. Fixes #2426 --- pygeoapi/process/manager/mongodb_.py | 10 ++++++++-- pygeoapi/process/manager/postgresql.py | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pygeoapi/process/manager/mongodb_.py b/pygeoapi/process/manager/mongodb_.py index 06e6d909ad..5479bea78a 100644 --- a/pygeoapi/process/manager/mongodb_.py +++ b/pygeoapi/process/manager/mongodb_.py @@ -79,9 +79,15 @@ def get_jobs(self, status=None, limit=None, offset=None): database = self.db.job_manager_pygeoapi collection = database.jobs if status is not None: - jobs = list(collection.find({}, {"status": status})) + query = {"status": status} else: - jobs = list(collection.find({})) + query = {} + cursor = collection.find(query) + if offset: + cursor = cursor.skip(offset) + if limit: + cursor = cursor.limit(limit) + jobs = list(cursor) LOGGER.info("JOBMANAGER - MongoDB jobs queried") return { 'jobs': jobs, diff --git a/pygeoapi/process/manager/postgresql.py b/pygeoapi/process/manager/postgresql.py index cfd63eafb8..180d6ba282 100644 --- a/pygeoapi/process/manager/postgresql.py +++ b/pygeoapi/process/manager/postgresql.py @@ -133,6 +133,11 @@ def get_jobs( if status is not None: results = results.filter(self.c.status == status.value) + if offset: + results = results.offset(offset) + if limit: + results = results.limit(limit) + jobs = [r._asdict() for r in results.all()] return {'jobs': jobs, 'numberMatched': len(jobs)}