diff --git a/spin-observatory-plugin-deck/src/components/pipelines/PipelineExecutions.tsx b/spin-observatory-plugin-deck/src/components/pipelines/PipelineExecutions.tsx index 3bd369f..07624d9 100644 --- a/spin-observatory-plugin-deck/src/components/pipelines/PipelineExecutions.tsx +++ b/spin-observatory-plugin-deck/src/components/pipelines/PipelineExecutions.tsx @@ -36,6 +36,7 @@ export const PipelineExecutions = ({ const [filteredExecutions, setFilteredExecutions] = useState([]); const [statusCount, setStatusCount] = useState>(new Map()); const [isLoading, setIsLoading] = useState(true); + const [isRequestInProgress, setIsRequestInProgress] = useState(false); const styles = useStyles(); const getExecutionsParams = { @@ -55,22 +56,11 @@ export const PipelineExecutions = ({ setFilteredExecutions([]); setStatusCount(new Map()); setIsLoading(false); + setIsRequestInProgress(false); return; } - const requestParams = { - pipelineName: pipeline.name, - pageSize: REQUEST_PAGE_SIZE, - startDate: dateRange.start, - endDate: dateRange.end, - }; - - gate.getExecutions(appName, requestParams).then((resp) => { - setExecutions(resp); - setFilteredExecutions(filterExecutions(resp)); - setStatusCount(getStatusCount(resp)); - setIsLoading(false); - }); + getExecutions(appName, getExecutionsParams); }, [pipeline, dateRange.start, dateRange.end]); useEffect(() => { @@ -83,19 +73,28 @@ export const PipelineExecutions = ({ useInterval(async () => { if (!pipeline) return; - const resp = await gate.getExecutions(appName, { - pipelineName: pipeline.name, - pageSize: REQUEST_PAGE_SIZE, - startDate: dateRange.start, - endDate: dateRange.end, - }); - - setExecutions(resp); - setFilteredExecutions(filterExecutions(resp)); - setStatusCount(getStatusCount(resp)); - setIsLoading(false); + + if (isRequestInProgress) return; + + getExecutions(appName, getExecutionsParams); }, POLL_DELAY_MS); + const getExecutions = (name, params) => { + setIsRequestInProgress(true); + + gate.getExecutions(name, params) + .then((resp) => { + setExecutions(resp); + setFilteredExecutions(filterExecutions(resp)); + setStatusCount(getStatusCount(resp)); + setIsLoading(false); + }) + .catch((e) => console.error('error retrieving executions: ', e)) + .finally(() => { + setIsRequestInProgress(false); + }); + }; + const filterExecutions = (ex: IExecution[]) => { const statusArr = statuses.length === 0 ? STATUSES : statuses; diff --git a/spin-observatory-plugin-deck/src/components/pipelines/constants.ts b/spin-observatory-plugin-deck/src/components/pipelines/constants.ts index ded7c25..c23105a 100644 --- a/spin-observatory-plugin-deck/src/components/pipelines/constants.ts +++ b/spin-observatory-plugin-deck/src/components/pipelines/constants.ts @@ -2,6 +2,6 @@ export const REQUEST_PAGE_SIZE = 5000; export const DEFAULT_ROWS_PER_PAGE = 10; -export const POLL_DELAY_MS = 10000; +export const POLL_DELAY_MS = 30000; export const MAX_DATE_RANGE = 9007199254740991;