Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download: Move extra channel metadata import to background #650

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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