Skip to content

Commit

Permalink
Download: Move extra channel metadata import to background
Browse files Browse the repository at this point in the history
Like the unavailable content thumbnails, move the download of the extra
channel metadata to the background instead of blocking the initial
starter pack download on it.

Helps: #592
  • Loading branch information
dbnicholson authored and manuq committed Jun 21, 2023
1 parent 96e8cbb commit 0e3d699
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions kolibri_explore_plugin/collectionviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@

PROGRESS_STEPS = {
"importing": 0.1,
"downloading": 0.8,
"tagging": 0.9,
"downloading": 0.9,
"completed": 1,
}

Expand Down Expand Up @@ -247,8 +246,8 @@ class DownloadStage(IntEnum):
IMPORTING_CHANNELS = auto()
IMPORTING_CONTENT = auto()
APPLYING_EXTERNAL_TAGS = auto()
IMPORTING_EXTRA_CHANNELS = auto()
FOREGROUND_COMPLETED = auto()
IMPORTING_EXTRA_CHANNELS = auto()
IMPORTING_ALL_THUMBNAILS = auto()
COMPLETED = auto()

Expand Down Expand Up @@ -444,7 +443,7 @@ def get_status(self):
progress = (
PROGRESS_STEPS["downloading"]
+ (
PROGRESS_STEPS["tagging"]
PROGRESS_STEPS["completed"]
- PROGRESS_STEPS["downloading"]
)
* current_task_number
Expand All @@ -453,17 +452,6 @@ def get_status(self):
else:
progress = PROGRESS_STEPS["downloading"]

elif self._stage == DownloadStage.IMPORTING_EXTRA_CHANNELS:
if total_tasks_number > 0:
progress = (
PROGRESS_STEPS["tagging"]
+ (PROGRESS_STEPS["completed"] - PROGRESS_STEPS["tagging"])
* current_task_number
/ total_tasks_number
)
else:
progress = PROGRESS_STEPS["tagging"]

elif self._stage >= DownloadStage.FOREGROUND_COMPLETED:
progress = PROGRESS_STEPS["completed"]

Expand Down Expand Up @@ -520,7 +508,11 @@ def _set_next_stage(self, user):
elif self._stage == DownloadStage.APPLYING_EXTERNAL_TAGS:
tasks = self._content_manifest.get_applyexternaltags_tasks()
elif self._stage == DownloadStage.IMPORTING_EXTRA_CHANNELS:
tasks = self._content_manifest.get_extra_channelimport_tasks()
# Download the remaining channel metadata in the background.
for (
task
) in self._content_manifest.get_extra_channelimport_tasks():
self._enqueue_background_task(user, task)
elif self._stage == DownloadStage.IMPORTING_ALL_THUMBNAILS:
# Download the remaining content thumbnails in the background.
for (
Expand Down

0 comments on commit 0e3d699

Please sign in to comment.