This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new acfcba15c84 Fix incorrect backfill duration calculation in Grid view 
(#58813)
acfcba15c84 is described below

commit acfcba15c8452fd4aad7ae85bc811df127252162
Author: Ephraim Anierobi <[email protected]>
AuthorDate: Fri Nov 28 15:38:44 2025 +0100

    Fix incorrect backfill duration calculation in Grid view (#58813)
    
    The duration was calculated using timedelta.seconds which,
     returns only the seconds component, not the total duration.
    This caused backfills lasting more than a day to show incorrect durations.
    
    Changed to use total_seconds() which correctly returns the full duration.
---
 .../src/airflow/api_fastapi/core_api/datamodels/ui/common.py      | 4 ++--
 .../src/airflow/api_fastapi/core_api/openapi/_private_ui.yaml     | 2 +-
 airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts   | 2 +-
 .../tests/unit/api_fastapi/core_api/routes/ui/test_grid.py        | 8 ++++----
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git 
a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/common.py 
b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/common.py
index 27d21f0508d..a18042b4960 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/common.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/common.py
@@ -81,10 +81,10 @@ class GridRunsResponse(BaseModel):
     run_type: DagRunType
 
     @computed_field
-    def duration(self) -> int:
+    def duration(self) -> float:
         if self.start_date:
             end_date = self.end_date or timezone.utcnow()
-            return (end_date - self.start_date).seconds
+            return (end_date - self.start_date).total_seconds()
         return 0
 
 
diff --git 
a/airflow-core/src/airflow/api_fastapi/core_api/openapi/_private_ui.yaml 
b/airflow-core/src/airflow/api_fastapi/core_api/openapi/_private_ui.yaml
index b4e93a4c9f2..cd1c666a592 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/openapi/_private_ui.yaml
+++ b/airflow-core/src/airflow/api_fastapi/core_api/openapi/_private_ui.yaml
@@ -1924,7 +1924,7 @@ components:
         run_type:
           $ref: '#/components/schemas/DagRunType'
         duration:
-          type: integer
+          type: number
           title: Duration
           readOnly: true
       type: object
diff --git a/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts 
b/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
index a9b70b7dbbb..87b621b3162 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
@@ -7810,7 +7810,7 @@ export const $GridRunsResponse = {
             '$ref': '#/components/schemas/DagRunType'
         },
         duration: {
-            type: 'integer',
+            type: 'number',
             title: 'Duration',
             readOnly: true
         }
diff --git 
a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_grid.py 
b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_grid.py
index 78218893af3..a3f8ba4e2ac 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_grid.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_grid.py
@@ -58,7 +58,7 @@ INNER_TASK_GROUP_SUB_TASK = "inner_task_group_sub_task"
 
 GRID_RUN_1 = {
     "dag_id": "test_dag",
-    "duration": 0,
+    "duration": 283996800.0,
     "end_date": "2024-12-31T00:00:00Z",
     "run_after": "2024-11-30T00:00:00Z",
     "run_id": "run_1",
@@ -69,7 +69,7 @@ GRID_RUN_1 = {
 
 GRID_RUN_2 = {
     "dag_id": "test_dag",
-    "duration": 0,
+    "duration": 283996800.0,
     "end_date": "2024-12-31T00:00:00Z",
     "run_after": "2024-11-30T00:00:00Z",
     "run_id": "run_2",
@@ -528,7 +528,7 @@ class TestGetGridDataEndpoint:
         assert response.json() == [
             {
                 "dag_id": "test_dag",
-                "duration": 0,
+                "duration": 283996800.0,
                 "end_date": "2024-12-31T00:00:00Z",
                 "run_after": "2024-11-30T00:00:00Z",
                 "run_id": "run_1",
@@ -538,7 +538,7 @@ class TestGetGridDataEndpoint:
             },
             {
                 "dag_id": "test_dag",
-                "duration": 0,
+                "duration": 283996800.0,
                 "end_date": "2024-12-31T00:00:00Z",
                 "run_after": "2024-11-30T00:00:00Z",
                 "run_id": "run_2",

Reply via email to