diff --git a/src/api/SwaggerApi.js b/src/api/SwaggerApi.js index 79acb9fb2a2a89d681bd7bd976acfe2ff153af5e..e7c47430fbb7f3814b12c1b928e846e9409a720a 100644 --- a/src/api/SwaggerApi.js +++ b/src/api/SwaggerApi.js @@ -342,20 +342,6 @@ export function useTagsAndCommitIds(onError) { return useAsync({ fcn: method, call: false, onError: onError, init: [] }); } -export function unpackParam(param) { - return { ...param }; -} - -export function useDeploymenStatistics() { - const api = useContext(apiContext); - const method = useCallAndUnpack( - api.apis.Statistics.operationHistory, - unpackParam - ); - - return useAsync({ fcn: method, call: false }); -} - export function unpackGitProject(project) { return { ...project }; } diff --git a/src/components/statistics/OperationChart/OperationChart.js b/src/components/statistics/OperationChart/OperationChart.js index 3c7d2dc7637ccdb0f27d8d92edc15ea42e3a30d6..d6198aa4946857d2e82bd31e7dddaa08a22a9d81 100644 --- a/src/components/statistics/OperationChart/OperationChart.js +++ b/src/components/statistics/OperationChart/OperationChart.js @@ -14,8 +14,11 @@ import { Tooltip } from "recharts"; -export default function OperationChart({ title, hook }) { - const [iocDeployments, getIOCDeployments] = hook(); +export default function OperationChart({ + title, + iocDeployments, + getIOCDeployments +}) { const theme = useTheme(); useEffect(() => { diff --git a/src/mocks/fixtures/OperationHistoryStatistics.json b/src/mocks/fixtures/OperationHistoryStatistics.json new file mode 100644 index 0000000000000000000000000000000000000000..92bbbc61c0f2bfdaebe4f916ef2414f3f62c2134 --- /dev/null +++ b/src/mocks/fixtures/OperationHistoryStatistics.json @@ -0,0 +1,74 @@ +{ + "operationStatistics": [ + { + "deploymentCount": 4879, + "commandCount": 2411, + "historyDate": "2023-09-14T22:00:00.000+00:00" + }, + { + "deploymentCount": 4879, + "commandCount": 2411, + "historyDate": "2023-09-15T22:00:00.000+00:00" + }, + { + "deploymentCount": 4879, + "commandCount": 2411, + "historyDate": "2023-09-16T22:00:00.000+00:00" + }, + { + "deploymentCount": 4884, + "commandCount": 2411, + "historyDate": "2023-09-17T22:00:00.000+00:00" + }, + { + "deploymentCount": 4890, + "commandCount": 2419, + "historyDate": "2023-09-18T22:00:00.000+00:00" + }, + { + "deploymentCount": 4897, + "commandCount": 2420, + "historyDate": "2023-09-19T22:00:00.000+00:00" + }, + { + "deploymentCount": 4919, + "commandCount": 2422, + "historyDate": "2023-09-20T22:00:00.000+00:00" + }, + { + "deploymentCount": 4933, + "commandCount": 2422, + "historyDate": "2023-09-21T22:00:00.000+00:00" + }, + { + "deploymentCount": 4933, + "commandCount": 2422, + "historyDate": "2023-09-22T22:00:00.000+00:00" + }, + { + "deploymentCount": 4933, + "commandCount": 2422, + "historyDate": "2023-09-23T22:00:00.000+00:00" + }, + { + "deploymentCount": 4933, + "commandCount": 2422, + "historyDate": "2023-09-24T22:00:00.000+00:00" + }, + { + "deploymentCount": 4933, + "commandCount": 2422, + "historyDate": "2023-09-25T22:00:00.000+00:00" + }, + { + "deploymentCount": 4933, + "commandCount": 2422, + "historyDate": "2023-09-26T22:00:00.000+00:00" + }, + { + "deploymentCount": 4933, + "commandCount": 2422, + "historyDate": "2023-09-27T22:00:00.000+00:00" + } + ] +} diff --git a/src/mocks/mockAPI.js b/src/mocks/mockAPI.js index 359d7307a3b71dae51fc089d59b7893f115e3799..cfd07411f646ca5475af9ada588c076e4cec61ab 100644 --- a/src/mocks/mockAPI.js +++ b/src/mocks/mockAPI.js @@ -232,6 +232,11 @@ function activeIocHistory(req) { return { body }; } +function operationHistory(req) { + const body = require("./fixtures/OperationHistoryStatistics.json"); + return { body }; +} + function calculateStatistics(req) { const params = getParameters(req, "/statistics/general/:val"); const validValues = [ @@ -302,7 +307,8 @@ const mockAPI = { currentlyActiveIocs, iocDeploymentHistory, activeIocHistory, - calculateStatistics + calculateStatistics, + operationHistory }, naming: { fetchIOCByName @@ -446,6 +452,11 @@ export const apiHandlers = [ qRegExp(".*/statistics/general/active_ioc_history"), mockAPI.statistics.activeIocHistory ), + makeHandler( + "GET", + qRegExp(".*/statistics/general/operation_history"), + mockAPI.statistics.operationHistory + ), makeHandler( "GET", qRegExp(".*/statistics/general/.*"), diff --git a/src/views/statistics/StatisticsView.js b/src/views/statistics/StatisticsView.js index 22b9ab73ab36d038da69a8cdba74e49d7dcea8a3..13900b2577989e8d12a8b629cf2d8bf7fc7c2d22 100644 --- a/src/views/statistics/StatisticsView.js +++ b/src/views/statistics/StatisticsView.js @@ -5,7 +5,6 @@ import { GlobalAppBarContext } from "@ess-ics/ce-ui-common"; import { RootContainer } from "../../components/common/Container/RootContainer"; import ActiveIOCChart from "../../components/statistics/ActiveIOCChart"; import DeploymentLineChart from "../../components/statistics/DeploymentLineChart"; -import { useDeploymenStatistics } from "../../api/SwaggerApi"; import { HostStatistics } from "../../components/statistics/HostStatistics"; import { IOCStatistics } from "../../components/statistics/IOCStatistics"; import OperationChart from "../../components/statistics/OperationChart/OperationChart"; @@ -37,6 +36,12 @@ export function StatisticsView() { call: false }); + const { value: operationStatistics, wrapper: getOperationStatistics } = + useAPIMethod({ + fcn: client.apis.Statistics.operationHistory, + call: false + }); + return ( <StyledRootContainer> <Grid @@ -64,7 +69,8 @@ export function StatisticsView() { <Paper className={classes.paper}> <OperationChart title="Operations over time" - hook={useDeploymenStatistics} + iocDeployments={operationStatistics} + getIOCDeployments={getOperationStatistics} /> </Paper> </Grid>