From 49b3015a16287bb4486aa64c5c26f05f7c22089c Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 30 Jan 2023 22:22:59 +0000 Subject: refactor(web/server): Remove unnecessary service indirections This change removes the unnecessary service classes where they are only used to forward data from the resource to the entities. Furthermore, DTOs are now moved from the service layer to the resources. --- .../src/components/portfolios/PortfolioResults.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'opendc-web/opendc-web-ui/src/components/portfolios/PortfolioResults.js') diff --git a/opendc-web/opendc-web-ui/src/components/portfolios/PortfolioResults.js b/opendc-web/opendc-web-ui/src/components/portfolios/PortfolioResults.js index f50105ed..62150fa7 100644 --- a/opendc-web/opendc-web-ui/src/components/portfolios/PortfolioResults.js +++ b/opendc-web/opendc-web-ui/src/components/portfolios/PortfolioResults.js @@ -57,14 +57,17 @@ function PortfolioResults({ projectId, portfolioId }) { const dataPerMetric = {} AVAILABLE_METRICS.forEach((metric) => { dataPerMetric[metric] = scenarios - .filter((scenario) => scenario.job?.results) - .map((scenario) => ({ - metric, - x: scenario.name, - y: mean(scenario.job.results[metric]), - errorY: std(scenario.job.results[metric]), - label, - })) + .filter((scenario) => scenario.jobs && scenario.jobs[scenario.jobs.length - 1].results) + .map((scenario) => { + const job = scenario.jobs[scenario.jobs.length - 1] + return { + metric, + x: scenario.name, + y: mean(job.results[metric]), + errorY: std(job.results[metric]), + label, + } + }) }) return dataPerMetric }, [scenarios]) -- cgit v1.2.3