From b15214578dd900f9cf846f8ba0990ec443fd5bc0 Mon Sep 17 00:00:00 2001 From: Jose Javier Merchante Date: Tue, 6 Aug 2024 14:55:24 +0200 Subject: [PATCH] [jobs] Fix job listing for missing data in Redis Fetching the job list failed when job data was missing in Redis. This update discards missing results and deletes the missing job entries from the registry, ensuring the job listing works correctly. Signed-off-by: Jose Javier Merchante --- sortinghat/core/jobs.py | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/sortinghat/core/jobs.py b/sortinghat/core/jobs.py index 81dc417c..0128df5a 100644 --- a/sortinghat/core/jobs.py +++ b/sortinghat/core/jobs.py @@ -104,21 +104,31 @@ def job_in_tenant(job, tenant): logger.debug("Retrieving list of jobs ...") queue = get_tenant_queue(tenant) - started_jobs = [find_job(id, tenant) - for id - in queue.started_job_registry.get_job_ids()] - deferred_jobs = [find_job(id, tenant) - for id - in queue.deferred_job_registry.get_job_ids()] - finished_jobs = [find_job(id, tenant) - for id - in queue.finished_job_registry.get_job_ids()] - failed_jobs = [find_job(id, tenant) - for id - in queue.failed_job_registry.get_job_ids()] - scheduled_jobs = [find_job(id, tenant) - for id - in queue.scheduled_job_registry.get_job_ids()] + started_jobs = django_rq.utils.get_jobs( + queue, + queue.started_job_registry.get_job_ids(), + queue.started_job_registry + ) + deferred_jobs = django_rq.utils.get_jobs( + queue, + queue.deferred_job_registry.get_job_ids(), + queue.deferred_job_registry + ) + finished_jobs = django_rq.utils.get_jobs( + queue, + queue.finished_job_registry.get_job_ids(), + queue.finished_job_registry + ) + failed_jobs = django_rq.utils.get_jobs( + queue, + queue.failed_job_registry.get_job_ids(), + queue.failed_job_registry + ) + scheduled_jobs = django_rq.utils.get_jobs( + queue, + queue.scheduled_job_registry.get_job_ids(), + queue.scheduled_job_registry + ) jobs = (queue.jobs + started_jobs + deferred_jobs + finished_jobs + failed_jobs + scheduled_jobs) jobs = (job for job in jobs if job_in_tenant(job, tenant))