Skip to content

Commit 2835c73

Browse files
committed
fix: add backwards compatibility for integration progress
1 parent 67d2713 commit 2835c73

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

cognition_objects/integration.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)