Skip to content

Commit

Permalink
No grid auto-refresh for backfill dag runs (#25042)
Browse files Browse the repository at this point in the history
* Update useGridData.ts

* Update useGridData.test.js

* Update useGridData.test.js
  • Loading branch information
yingxuanwangxuan committed Jul 20, 2022
1 parent 38d6c28 commit de6938e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
30 changes: 25 additions & 5 deletions airflow/www/static/js/api/useGridData.test.js
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion airflow/www/static/js/api/useGridData.ts
Expand Up @@ -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();
Expand Down

0 comments on commit de6938e

Please sign in to comment.