bbovenzi commented on code in PR #23392:
URL: https://github.com/apache/airflow/pull/23392#discussion_r864886980
##########
airflow/www/static/js/grid/api/useGridData.js:
##########
@@ -17,41 +17,45 @@
* under the License.
*/
-/* global gridData, autoRefreshInterval */
+/* global autoRefreshInterval */
import { useQuery } from 'react-query';
import axios from 'axios';
import { getMetaValue } from '../../utils';
import { useAutoRefresh } from '../context/autorefresh';
-import { formatData, areActiveRuns } from '../utils/gridData';
+import { areActiveRuns } from '../utils/gridData';
import useErrorToast from '../utils/useErrorToast';
+import useFilters, {
+ BASE_DATE_PARAM, NUM_RUNS_PARAM, RUN_STATE_PARAM, RUN_TYPE_PARAM,
+} from '../utils/useFilters';
+
+const DAG_ID_PARAM = 'dag_id';
// dagId comes from dag.html
-const dagId = getMetaValue('dag_id');
+const dagId = getMetaValue(DAG_ID_PARAM);
const gridDataUrl = getMetaValue('grid_data_url') || '';
-const numRuns = getMetaValue('num_runs');
const urlRoot = getMetaValue('root');
-const baseDate = getMetaValue('base_date');
-
-const emptyData = {
- dagRuns: [],
- groups: {},
-};
const useGridData = () => {
- const initialData = formatData(gridData, emptyData);
const { isRefreshOn, stopRefresh } = useAutoRefresh();
const errorToast = useErrorToast();
- return useQuery('gridData', async () => {
- try {
- const params = new URLSearchParams({
- dag_id: dagId,
- });
- if (numRuns && numRuns !== 25) params.append('num_runs', numRuns);
- if (urlRoot) params.append('root', urlRoot);
- if (baseDate) params.append('base_date', baseDate);
+ const {
+ filters: {
+ baseDate, numRuns, runType, runState,
+ },
+ } = useFilters();
+ const { data, isSuccess, ...rest } = useQuery(['useGridData', baseDate,
numRuns, runType, runState], async () => {
Review Comment:
Changing the query key is also causing some issues. I'll try to get a commit
to this branch to fix all the react-query stuff soon.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]