You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2022/08/15 18:44:54 UTC

[airflow] 18/45: No grid auto-refresh for backfill dag runs (#25042)

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

ephraimanierobi pushed a commit to branch v2-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 7d2e516eaf6dbe8e4d1b23355d57359d61fae06c
Author: yingxuanwangxuan <95...@users.noreply.github.com>
AuthorDate: Wed Jul 20 18:30:22 2022 +0800

    No grid auto-refresh for backfill dag runs (#25042)
    
    * Update useGridData.ts
    
    * Update useGridData.test.js
    
    * Update useGridData.test.js
    
    (cherry picked from commit de6938e173773d88bd741e43c7b0aa16d8a1a167)
---
 airflow/www/static/js/grid/api/useGridData.test.js | 30 ++++++++++++++++++----
 airflow/www/static/js/grid/api/useGridData.ts      |  2 +-
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/airflow/www/static/js/grid/api/useGridData.test.js b/airflow/www/static/js/grid/api/useGridData.test.js
index 29a7f1ac8a..f8c7d451c6 100644
--- a/airflow/www/static/js/grid/api/useGridData.test.js
+++ b/airflow/www/static/js/grid/api/useGridData.test.js
@@ -24,17 +24,37 @@ import { areActiveRuns } from './useGridData';
 describe('Test areActiveRuns()', () => {
   test('Correctly detects active runs', () => {
     const runs = [
-      { state: 'success' },
-      { state: 'queued' },
+      { runType: 'scheduled', state: 'success' },
+      { runType: 'manual', state: 'queued' },
     ];
     expect(areActiveRuns(runs)).toBe(true);
   });
 
   test('Returns false when all runs are resolved', () => {
     const runs = [
-      { state: 'success' },
-      { state: 'failed' },
-      { state: 'not_queued' },
+      { runType: 'scheduled', state: 'success' },
+      { runType: 'manual', state: 'failed' },
+      { runType: 'manual', state: 'not_queued' },
+    ];
+    const result = areActiveRuns(runs);
+    expect(result).toBe(false);
+  });
+
+  test('Returns false when filtering runs runtype ["backfill"] and state ["not_queued"]', () => {
+    const runs = [
+      { runType: 'scheduled', state: 'success' },
+      { runType: 'manual', state: 'failed' },
+      { runType: 'backfill', state: 'not_queued' },
+    ];
+    const result = areActiveRuns(runs);
+    expect(result).toBe(false);
+  });
+
+  test('Returns false when filtering runs runtype ["backfill"] and state ["queued"]', () => {
+    const runs = [
+      { runType: 'scheduled', state: 'success' },
+      { runType: 'manual', state: 'failed' },
+      { runType: 'backfill', state: 'queued' },
     ];
     const result = areActiveRuns(runs);
     expect(result).toBe(false);
diff --git a/airflow/www/static/js/grid/api/useGridData.ts b/airflow/www/static/js/grid/api/useGridData.ts
index ec12ee6d60..3af43df9b1 100644
--- a/airflow/www/static/js/grid/api/useGridData.ts
+++ b/airflow/www/static/js/grid/api/useGridData.ts
@@ -49,7 +49,7 @@ const emptyGridData: GridData = {
   },
 };
 
-export const areActiveRuns = (runs: DagRun[] = []) => runs.filter((run) => ['queued', 'running', 'scheduled'].includes(run.state)).length > 0;
+export const areActiveRuns = (runs: DagRun[] = []) => runs.filter((run) => ['manual', 'manual'].includes(run.runType)).filter((run) => ['queued', 'running', 'scheduled'].includes(run.state)).length > 0;
 
 const useGridData = () => {
   const { isRefreshOn, stopRefresh } = useAutoRefresh();