Skip to content

Commit

Permalink
Limit progress integers to less than or equal to 10000
Browse files Browse the repository at this point in the history
  • Loading branch information
bjester committed Mar 19, 2024
1 parent cb9c66d commit 6ec6b41
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/android_app_plugin/kolibri_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

Locale = autoclass("java.util.Locale")
Task = autoclass("org.learningequality.Task")
PROGRESS_LIMIT = 10000


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -68,6 +69,13 @@ def update(self, job, orm_job, state=None, **kwargs):
else:
progress = -1
total_progress = -1

# avoid passing integers that are too large
# PROGRESS_LIMIT gives sufficient precision for a % progress calculation
if total_progress > PROGRESS_LIMIT:
progress = progress // total_progress * PROGRESS_LIMIT
total_progress = PROGRESS_LIMIT

Task.updateProgress(
orm_job.worker_extra,
status.title,
Expand Down

0 comments on commit 6ec6b41

Please sign in to comment.