Skip to content

Commit

Permalink
Sort jobs before pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
totycro committed Aug 8, 2024
1 parent 0ff5d55 commit 1cfe622
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.5.2
* Jobs pagination sorting

## 1.5.1
* Jobs pagination fix

Expand Down
22 changes: 15 additions & 7 deletions pygeoapi_kubernetes_papermill/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,21 @@ def get_jobs(self, status=None, limit=None, offset=None) -> dict:
and numberMatched
"""

k8s_jobs = [
k8s_job
for k8s_job in self.batch_v1.list_namespaced_job(
namespace=self.namespace,
).items
if is_k8s_job_name(k8s_job.metadata.name)
]
def get_start_time_from_job(job: k8s_client.V1Job) -> str:
key = format_annotation_key("job_start_datetime")
return job.metadata.annotations.get(key, "")

k8s_jobs = sorted(
(
k8s_job
for k8s_job in self.batch_v1.list_namespaced_job(
namespace=self.namespace,
).items
if is_k8s_job_name(k8s_job.metadata.name)
),
key=get_start_time_from_job,
reverse=True,
)

number_matched = len(k8s_jobs)

Expand Down

0 comments on commit 1cfe622

Please sign in to comment.