Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No grid auto-refresh for backfill dag runs #25042

Merged
merged 7 commits into from Jul 20, 2022
Merged
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely this should be:

export const areActiveRuns = (runs: DagRun[] = []) => runs.filter((run) => ['scheduled', 'manual'].includes(run.runType)).filter((run) => ['queued', 'running', 'scheduled'].includes(run.state)).length > 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fix this. @bbovenzi can you review it again?


const useGridData = () => {
const { isRefreshOn, stopRefresh } = useAutoRefresh();
Expand Down