Merge pull request 'refactor(jobs):track 100-on-finished as a progress update' (#44) from fix-no-updates-if-delayed into master

Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api/pulls/44
This commit is contained in:
houkime 2023-07-21 16:30:28 +03:00
commit c5b7ca7565

View file

@ -198,12 +198,15 @@ class Jobs:
job.description = description job.description = description
if status_text is not None: if status_text is not None:
job.status_text = status_text job.status_text = status_text
if status == JobStatus.FINISHED:
job.progress = 100 # if it is finished it is 100
if progress is not None: # unless user says otherwise
# explicitly provided progress has priority if status == JobStatus.FINISHED and progress is None:
progress = 100
if progress is not None and job.progress != progress:
job.progress = progress job.progress = progress
Jobs.log_progress_update(job, progress) Jobs.log_progress_update(job, progress)
job.status = status job.status = status
Jobs.log_status_update(job, status) Jobs.log_status_update(job, status)
job.updated_at = datetime.datetime.now() job.updated_at = datetime.datetime.now()