File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -185,15 +185,27 @@ def get_integration_progress(
185185) -> float :
186186 integration = get_by_id (integration_id )
187187 count_all_records = integration_records_bo .count (integration )
188- all_tasks = get_all_etl_tasks (integration_id )
189- finished_tasks = [task for task in all_tasks if task .state in FINISHED_STATES ]
190188
191189 if (
192190 count_all_records == 0
193191 or integration .state == enums .CognitionMarkdownFileState .FAILED .value
194192 ):
195193 return 0.0
196- integration_progress = round ((len (finished_tasks ) / count_all_records ) * 100.0 , 2 )
194+
195+ all_tasks = get_all_etl_tasks (integration_id )
196+ finished_tasks = [task for task in all_tasks if task .state in FINISHED_STATES ]
197+ count_finished_tasks = len (finished_tasks )
198+
199+ # backward compatibility
200+ if not all_tasks or len (all_tasks ) != count_all_records :
201+ all_records , _ = integration_records_bo .get_all_by_integration_id (
202+ integration_id
203+ )
204+ count_finished_tasks += len (
205+ [record for record in all_records if not record .etl_task_id ]
206+ )
207+
208+ integration_progress = round ((count_finished_tasks / count_all_records ) * 100.0 , 2 )
197209 if integration .state not in FINISHED_STATES :
198210 integration_progress = min (integration_progress - 1 , 0 )
199211 return integration_progress
You can’t perform that action at this time.
0 commit comments