Skip to content

Commit

Permalink
refactor request to gate
Browse files Browse the repository at this point in the history
  • Loading branch information
Abel Rodriguez committed Sep 27, 2023
1 parent 64df455 commit d831b1a
Showing 1 changed file with 22 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,7 @@ export const PipelineExecutions = ({
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);
setIsRequestInProgress(false);
});
getExecutions(appName, getExecutionsParams);
}, [pipeline, dateRange.start, dateRange.end]);

useEffect(() => {
Expand All @@ -94,24 +81,30 @@ export const PipelineExecutions = ({
console.log("end useInterval");
return;
}

setIsRequestInProgress(true);
console.log("making a request...");
const resp = await gate.getExecutions(appName, {
pipelineName: pipeline.name,
pageSize: REQUEST_PAGE_SIZE,
startDate: dateRange.start,
endDate: dateRange.end,
});
console.log("request completed");
setExecutions(resp);
setFilteredExecutions(filterExecutions(resp));
setStatusCount(getStatusCount(resp));
setIsLoading(false);
setIsRequestInProgress(false);

getExecutions(appName, getExecutionsParams);
console.log("end useInterval");
}, POLL_DELAY_MS);

const getExecutions = (name, params) => {
setIsRequestInProgress(true);
console.log("making a request...");

gate.getExecutions(name, params)
.then((resp) => {
console.log("request completed");

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;

Expand Down

0 comments on commit d831b1a

Please sign in to comment.