@@ -21,7 +21,8 @@ def __init__(self,
2121 total = None ,
2222 unit = 'it' ,
2323 unit_divisor = 1000 ,
24- parent_task_id = None
24+ parent_task_id = None ,
25+ cumulate2parents = True , # deprecated see #57
2526 ):
2627 """
2728 Parameters
@@ -32,6 +33,10 @@ def __init__(self,
3233 unit: str, optional: String that will be used to define the unit of each iteration
3334 unit_divisor: int, optional
3435 parent_task_id: int, optional: Huey Task ID if a parent Tasks exists.
36+ cumulate2parents: bool, optional: option to cumulate progress to the parent task progress
37+ Note: parent_task_id must be provided to cumulate progress to the parent task progress
38+ this option will be removed in the future, see:
39+ https://github.com/boxine/django-huey-monitor/discussions/57
3540 """
3641 assert isinstance (task , Task ), f'No task given: { task !r} (Hint: use "context=True")'
3742 self .task = task
@@ -40,6 +45,7 @@ def __init__(self,
4045 self .unit = unit
4146 self .unit_divisor = unit_divisor
4247 self .parent_task_id = parent_task_id
48+ self .cumulate2parents = cumulate2parents
4349
4450 if len (self .desc ) > 64 :
4551 # We call .update() that will not validate the data, so a overlong
@@ -80,13 +86,15 @@ def update(self, n=1):
8086 if self .parent_task_id :
8187 # Store information for main task, too:
8288 ids .append (self .parent_task_id )
83- objects .append (
84- TaskProgressModel (
85- task_id = self .parent_task_id ,
86- progress_count = n ,
87- create_dt = now
89+
90+ if self .cumulate2parents :
91+ objects .append (
92+ TaskProgressModel (
93+ task_id = self .parent_task_id ,
94+ progress_count = n ,
95+ create_dt = now
96+ )
8897 )
89- )
9098
9199 TaskProgressModel .objects .bulk_create (objects )
92100
0 commit comments