From 16d2777a3d74c1c54ceeb6aef48b9bf0d259eae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Moreno?= Date: Wed, 13 Jul 2022 10:32:56 +0200 Subject: [PATCH] Improve download job handling https://phabricator.endlessm.com/T33570 --- kolibri_explore_plugin/views.py | 7 ++++++- .../eos-components/src/components/InstallContentModal.vue | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kolibri_explore_plugin/views.py b/kolibri_explore_plugin/views.py index c1c8c628d..525d1d0ca 100644 --- a/kolibri_explore_plugin/views.py +++ b/kolibri_explore_plugin/views.py @@ -22,6 +22,7 @@ from kolibri.core.decorators import cache_no_user_data from kolibri.core.tasks.api import _job_to_response from kolibri.core.tasks.api import _remoteimport +from kolibri.core.tasks.exceptions import JobNotFound from kolibri.core.tasks.job import State from kolibri.core.tasks.main import queue from kolibri.utils import conf @@ -192,7 +193,11 @@ def check_collection_availability(self): def get(self, request): job_ids = request.session.get("job_ids", []) - jobs = [queue.fetch_job(job) for job in job_ids] + try: + jobs = [queue.fetch_job(job) for job in job_ids] + except JobNotFound: + request.session["job_ids"] = [] + jobs = [] running = [job for job in jobs if job.state == State.RUNNING] pid, _, _ = get_status() diff --git a/packages/eos-components/src/components/InstallContentModal.vue b/packages/eos-components/src/components/InstallContentModal.vue index 1a4ef467c..0cda7968f 100644 --- a/packages/eos-components/src/components/InstallContentModal.vue +++ b/packages/eos-components/src/components/InstallContentModal.vue @@ -155,7 +155,12 @@ axios.get(ApiURL).then(({ data }) => { this.jobs = data.jobs; const completedJobs = this.jobs.filter(j => j.status === 'COMPLETED'); + const queuedJobs = this.jobs.filter(j => j.status === 'QUEUED'); const completed = completedJobs.length; + console.log('Downloading: '); + console.log(` Total Jobs: ${this.jobs.length}`); + console.log(` Queued: ${queuedJobs.length}`); + console.log(` Completed: ${completedJobs.length}`); if (completed > 0 && completed === this.jobs.length) { // Download is completed