diff --git a/api/src/modules/impact/reports/csv-data.builder.ts b/api/src/modules/impact/reports/impact-report-dto.builder.ts similarity index 96% rename from api/src/modules/impact/reports/csv-data.builder.ts rename to api/src/modules/impact/reports/impact-report-dto.builder.ts index cfd1b91ad..8a818a544 100644 --- a/api/src/modules/impact/reports/csv-data.builder.ts +++ b/api/src/modules/impact/reports/impact-report-dto.builder.ts @@ -8,10 +8,10 @@ import { ActualVsScenarioImpactTableRowsValues } from 'modules/impact/dto/respon import { ImpactTableCSVReport } from 'modules/impact/reports/types'; /** - * @description Handles the building of the object, for each row that it will be parsed to CSV + * @description Handles the building of the DTO for the CSV report */ -export class CsvDataBuilder { +export class ImpactReportDtoBuilder { csvData: ImpactTableCSVReport; currentNodeName: string; yearKey: string; @@ -72,7 +72,7 @@ export class CsvDataBuilder { this.yearKey = year.toString(); } - setProjectedYear(): void { + setYearAsProjected(): void { this.yearKey = this.yearKey.concat(' (projected)'); } diff --git a/api/src/modules/impact/reports/impact-report.parser.ts b/api/src/modules/impact/reports/impact-report.parser.ts index 76963aa1b..564a97f5a 100644 --- a/api/src/modules/impact/reports/impact-report.parser.ts +++ b/api/src/modules/impact/reports/impact-report.parser.ts @@ -10,7 +10,7 @@ import { ImpactTableToCSVInput, } from 'modules/impact/reports/types'; import { Injectable } from '@nestjs/common'; -import { CsvDataBuilder } from 'modules/impact/reports/csv-data.builder'; +import { ImpactReportDtoBuilder } from 'modules/impact/reports/impact-report-dto.builder'; import { ScenarioVsScenarioImpactTableRowsValues } from 'modules/impact/dto/response-scenario-scenario.dto'; import { ActualVsScenarioImpactTableRowsValues } from 'modules/impact/dto/response-actual-scenario.dto'; @@ -43,36 +43,37 @@ export class ImpactReportDataParser { groupBy: GROUP_BY_VALUES, unit: string, accumulator: ImpactTableCSVReport[], - parentName?: string | null, + parentNodeName?: string | null, ): void { - const parsedDataBuilder: CsvDataBuilder = new CsvDataBuilder(); - parsedDataBuilder.setIndicatorWithUnit(indicatorName, unit); - parsedDataBuilder.setGroupingAndNodeName(groupBy, node.name, parentName); + const reportDtoBuilder: ImpactReportDtoBuilder = + new ImpactReportDtoBuilder(); + reportDtoBuilder.setIndicatorWithUnit(indicatorName, unit); + reportDtoBuilder.setGroupingAndNodeName(groupBy, node.name, parentNodeName); node.values.forEach((valuesOfNode: AnyImpactTableRowsValues) => { - parsedDataBuilder.setBaseYearKey(valuesOfNode.year); - if (parsedDataBuilder.isYearProjected(valuesOfNode)) { - parsedDataBuilder.setProjectedYear(); + reportDtoBuilder.setBaseYearKey(valuesOfNode.year); + if (reportDtoBuilder.isYearProjected(valuesOfNode)) { + reportDtoBuilder.setYearAsProjected(); } - if (parsedDataBuilder.isScenarioVsScenario(valuesOfNode)) { - parsedDataBuilder.setScenarioVsScenarioValues( + if (reportDtoBuilder.isScenarioVsScenario(valuesOfNode)) { + reportDtoBuilder.setScenarioVsScenarioValues( valuesOfNode as ScenarioVsScenarioImpactTableRowsValues, ); } - if (parsedDataBuilder.isActualVsScenario(valuesOfNode)) { - parsedDataBuilder.setActualVsScenarioValues( + if (reportDtoBuilder.isActualVsScenario(valuesOfNode)) { + reportDtoBuilder.setActualVsScenarioValues( valuesOfNode as ActualVsScenarioImpactTableRowsValues, ); } - if (parsedDataBuilder.isOnlyActualData(valuesOfNode)) { - parsedDataBuilder.setActualDataValues( + if (reportDtoBuilder.isOnlyActualData(valuesOfNode)) { + reportDtoBuilder.setActualDataValues( valuesOfNode as ImpactTableRowsValues, ); } }); - accumulator.push(parsedDataBuilder.build()); + accumulator.push(reportDtoBuilder.build()); if (node.children && node.children.length) { - const currentNodeName: string = parsedDataBuilder.getCurrentNodeName(); + const currentNodeName: string = reportDtoBuilder.getCurrentNodeName(); node.children.forEach((children: AnyImpactTableRows) => { this.parseNode( children,