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

potiuk pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-1-test by this push:
     new 053aec87696 [v3-1-test] Fix incorrect backfill duration calculation in 
Grid view (#58813) (#58816)
053aec87696 is described below

commit 053aec876967be08e51db2e0b494eed566cdc086
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Nov 28 19:13:47 2025 +0100

    [v3-1-test] Fix incorrect backfill duration calculation in Grid view 
(#58813) (#58816)
    
    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.
    (cherry picked from commit acfcba15c8452fd4aad7ae85bc811df127252162)
    
    Co-authored-by: Ephraim Anierobi <[email protected]>
---
 .../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 2dee03e6510..6c96367da2e 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 0d4aec69997..7ff73105164 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
@@ -1824,7 +1824,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 3f0ebb2b821..e45ee585988 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
@@ -7447,7 +7447,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 80f11a2c341..4b0818dc1c5 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