Skip to content

Commit

Permalink
Improve docstring for update_task_status
Browse files Browse the repository at this point in the history
  • Loading branch information
Eg0ra committed Dec 20, 2024
1 parent 5a23598 commit 4072aee
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions import_export_extensions/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,29 @@ def update_task_state(
):
"""Update state of the current event.
Receives meta of the current task and increase the `current`.
Receives meta of the current task and increase the `current`. Task
state is updated when current item is a multiple of
`self.status_update_row_count` or equal to total number of items.
For example: once every 1000 objects (if the current object is 1000,
2000, 3000) or when current object is the last object, in order to
complete the import/export.
This needed to increase the speed of import/export by reducing number
of task status updates.
"""
if not current_task or current_task.request.called_directly:
return

self.current_object_number += 1
if (

is_reached_update_count = (
self.current_object_number % self.status_update_row_count == 0
or self.current_object_number == self.total_objects_count
):
)
is_last_object = self.current_object_number == self.total_objects_count

if is_reached_update_count or is_last_object:
self._update_current_task_state(
state=state,
meta={
Expand Down

0 comments on commit 4072aee

Please sign in to comment.