Skip to content

Commit

Permalink
Improve download job handling
Browse files Browse the repository at this point in the history
  • Loading branch information
danigm committed Jul 14, 2022
1 parent 53cf7b2 commit 195f340
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kolibri_explore_plugin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 195f340

Please sign in to comment.