diff --git a/api/src/modules/indicator-coefficients/dto/indicator-coefficients.dto.ts b/api/src/modules/indicator-coefficients/dto/indicator-coefficients.dto.ts index 382f34ee11..72cda3ec1d 100644 --- a/api/src/modules/indicator-coefficients/dto/indicator-coefficients.dto.ts +++ b/api/src/modules/indicator-coefficients/dto/indicator-coefficients.dto.ts @@ -8,7 +8,7 @@ export class IndicatorCoefficientsDto { @Max(1000000) @Min(0) @IsNumber() - [INDICATOR_NAME_CODES.WATER_USE]: number; + [INDICATOR_NAME_CODES.LF]: number; @ApiPropertyOptional() @IsOptional() @@ -16,7 +16,7 @@ export class IndicatorCoefficientsDto { @Min(0) @IsNotEmpty() @IsNumber() - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: number; + [INDICATOR_NAME_CODES.DF_SLUC]: number; @ApiPropertyOptional() @IsOptional() @@ -24,7 +24,7 @@ export class IndicatorCoefficientsDto { @Min(0) @IsNotEmpty() @IsNumber() - [INDICATOR_NAME_CODES.CLIMATE_RISK]: number; + [INDICATOR_NAME_CODES.GHG_DEF_SLUC]: number; @ApiPropertyOptional() @IsOptional() @@ -32,7 +32,7 @@ export class IndicatorCoefficientsDto { @Min(0) @IsNotEmpty() @IsNumber() - [INDICATOR_NAME_CODES.DEFORESTATION_RISK]: number; + [INDICATOR_NAME_CODES.GHG_FARM]: number; @ApiPropertyOptional() @IsOptional() @@ -40,7 +40,7 @@ export class IndicatorCoefficientsDto { @Min(0) @IsNotEmpty() @IsNumber() - [INDICATOR_NAME_CODES.LAND_USE]: number; + [INDICATOR_NAME_CODES.UWU]: number; @ApiPropertyOptional() @IsOptional() @@ -48,7 +48,7 @@ export class IndicatorCoefficientsDto { @Min(0) @IsNotEmpty() @IsNumber() - [INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION]: number; + [INDICATOR_NAME_CODES.WU]: number; @ApiPropertyOptional() @IsOptional() @@ -56,7 +56,7 @@ export class IndicatorCoefficientsDto { @Min(0) @IsNotEmpty() @IsNumber() - [INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION_RISK]: number; + [INDICATOR_NAME_CODES.NL]: number; @ApiPropertyOptional() @IsOptional() @@ -64,7 +64,7 @@ export class IndicatorCoefficientsDto { @Min(0) @IsNotEmpty() @IsNumber() - [INDICATOR_NAME_CODES.NATURAL_ECOSYSTEM_CONVERSION_RISK]: number; + [INDICATOR_NAME_CODES.ENL]: number; @ApiPropertyOptional() @IsOptional() @@ -72,5 +72,5 @@ export class IndicatorCoefficientsDto { @Min(0) @IsNotEmpty() @IsNumber() - [INDICATOR_NAME_CODES.WATER_QUALITY]: number; + [INDICATOR_NAME_CODES.NCE]: number; } diff --git a/api/src/modules/indicator-records/services/impact-calculation.dependencies.ts b/api/src/modules/indicator-records/services/impact-calculation.dependencies.ts index 52742c4846..ba9af4c116 100644 --- a/api/src/modules/indicator-records/services/impact-calculation.dependencies.ts +++ b/api/src/modules/indicator-records/services/impact-calculation.dependencies.ts @@ -60,48 +60,45 @@ export const INDICATOR_NAME_CODE_TO_QUERY_MAP: { [key in ImpactQueryPropertyName]?: ImpactPropertyToQueryFunction; }; } = { - [INDICATOR_NAME_CODES.LAND_USE]: { + [INDICATOR_NAME_CODES.LF]: { harvest: () => `sum_material_over_georegion($1, $2, 'harvest') as "${QueryPropertyNames.harvest}"`, production: () => `sum_material_over_georegion($1, $2, 'producer') as "${QueryPropertyNames.production}"`, }, - [INDICATOR_NAME_CODES.DEFORESTATION_RISK]: { + [INDICATOR_NAME_CODES.DF_SLUC]: { production: () => `sum_material_over_georegion($1, $2, 'producer') as "${QueryPropertyNames.production}"`, rawDeforestation: (nameCode: INDICATOR_NAME_CODES) => `get_annual_landscape_impact_over_georegion($1, '${nameCode}', $2, 'producer') as "${QueryPropertyNames.rawDeforestation}"`, }, - [INDICATOR_NAME_CODES.CLIMATE_RISK]: { + [INDICATOR_NAME_CODES.GHG_DEF_SLUC]: { production: () => `sum_material_over_georegion($1, $2, 'producer') as "${QueryPropertyNames.production}"`, rawClimateRisk: (nameCode: INDICATOR_NAME_CODES) => `get_annual_landscape_impact_over_georegion($1,'${nameCode}', $2, 'producer') as "${QueryPropertyNames.rawClimateRisk}"`, }, - [INDICATOR_NAME_CODES.WATER_QUALITY]: { + [INDICATOR_NAME_CODES.GHG_FARM]: { rawWaterQuality: (nameCode: INDICATOR_NAME_CODES) => `get_indicator_coefficient_impact('${nameCode}', $3, $2) as "${QueryPropertyNames.rawWaterQuality}"`, }, - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: { + [INDICATOR_NAME_CODES.UWU]: { rawUnsustainableWaterUse: (nameCode: INDICATOR_NAME_CODES) => `get_percentage_water_stress_area($1, '${nameCode}') as "${QueryPropertyNames.rawUnsustainableWaterUse}"`, }, - [INDICATOR_NAME_CODES.NATURAL_ECOSYSTEM_CONVERSION_RISK]: { - production: () => - `sum_material_over_georegion($1, $2, 'producer') as "${QueryPropertyNames.production}"`, - rawNaturalConversion: (nameCode: INDICATOR_NAME_CODES) => - `get_annual_landscape_impact_over_georegion($1, '${nameCode}', $2, 'producer') as "${QueryPropertyNames.rawNaturalConversion}"`, + [INDICATOR_NAME_CODES.WU]: { + rawWaterUse: (nameCode: INDICATOR_NAME_CODES) => 'to be implemented', }, - [INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION]: { - satDeforestation: () => - ` sum_satelligence_deforestation_over_georegion($1) as "${QueryPropertyNames.satDeforestation}"`, + [INDICATOR_NAME_CODES.NL]: { + rawNaturalConversion: (nameCode: INDICATOR_NAME_CODES) => + 'to be implemented', }, - [INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION_RISK]: { - satDeforestationRisk: () => - `sum_satelligence_deforestation_risk_over_georegion($1) as "${QueryPropertyNames.satDeforestationRisk}"`, + [INDICATOR_NAME_CODES.ENL]: { + rawNaturalConversion: (nameCode: INDICATOR_NAME_CODES) => + 'to be implemented', }, - [INDICATOR_NAME_CODES.WATER_USE]: { - rawWaterUse: (nameCode: INDICATOR_NAME_CODES) => - `get_indicator_coefficient_impact('${nameCode}', $3, $2) as "${QueryPropertyNames.rawWaterUse}"`, + [INDICATOR_NAME_CODES.NCE]: { + rawNaturalConversion: (nameCode: INDICATOR_NAME_CODES) => + 'to be implemented', }, }; diff --git a/api/src/modules/indicator-records/services/impact-calculator.service.ts b/api/src/modules/indicator-records/services/impact-calculator.service.ts index 2da7d24b04..d0f92e3d84 100644 --- a/api/src/modules/indicator-records/services/impact-calculator.service.ts +++ b/api/src/modules/indicator-records/services/impact-calculator.service.ts @@ -271,38 +271,32 @@ export class ImpactCalculator { calculatedIndicatorValues.materialH3DataId = materialH3DataId; calculatedIndicatorValues.values = new Map(); calculatedIndicatorValues.values.set( - INDICATOR_NAME_CODES.LAND_USE, - newIndicatorCoefficients[INDICATOR_NAME_CODES.LAND_USE] * + INDICATOR_NAME_CODES.LF, + newIndicatorCoefficients[INDICATOR_NAME_CODES.LF] * sourcingData.tonnage || 0, ); calculatedIndicatorValues.values.set( - INDICATOR_NAME_CODES.DEFORESTATION_RISK, - newIndicatorCoefficients[INDICATOR_NAME_CODES.DEFORESTATION_RISK] * + INDICATOR_NAME_CODES.DF_SLUC, + newIndicatorCoefficients[INDICATOR_NAME_CODES.DF_SLUC] * sourcingData.tonnage || 0, ); calculatedIndicatorValues.values.set( - INDICATOR_NAME_CODES.CLIMATE_RISK, - newIndicatorCoefficients[INDICATOR_NAME_CODES.CLIMATE_RISK] * + INDICATOR_NAME_CODES.GHG_DEF_SLUC, + newIndicatorCoefficients[INDICATOR_NAME_CODES.GHG_DEF_SLUC] * sourcingData.tonnage || 0, ); calculatedIndicatorValues.values.set( - INDICATOR_NAME_CODES.WATER_USE, - newIndicatorCoefficients[INDICATOR_NAME_CODES.WATER_USE] * + INDICATOR_NAME_CODES.WU, + newIndicatorCoefficients[INDICATOR_NAME_CODES.WU] * sourcingData.tonnage || 0, ); - - // TODO: We need to ignore satelligence indicators from being affected by a coefficient that a user can send - // updating the model will be required for this, as by default any indicator that is active will be shown - // in the UI, also for sending coefficients in intervention calculation - - // Depends on water use indicator's final value const waterUseValue: number = calculatedIndicatorValues.values.get( - INDICATOR_NAME_CODES.WATER_USE, + INDICATOR_NAME_CODES.WU, )!; calculatedIndicatorValues.values.set( - INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, + INDICATOR_NAME_CODES.UWU, waterUseValue * - newIndicatorCoefficients[INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE] * + newIndicatorCoefficients[INDICATOR_NAME_CODES.UWU] * sourcingData.tonnage, ); @@ -350,27 +344,16 @@ export class ImpactCalculator { const waterQuality: number = rawData.rawWaterQuality * tonnage; const map: Map = new Map(); - map.set(INDICATOR_NAME_CODES.DEFORESTATION_RISK, deforestation); - map.set(INDICATOR_NAME_CODES.CLIMATE_RISK, climateRisk); - map.set( - INDICATOR_NAME_CODES.NATURAL_ECOSYSTEM_CONVERSION_RISK, - naturalRisk, - ); - map.set( - INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, - unsustainableWaterUse, - ); - map.set(INDICATOR_NAME_CODES.WATER_USE, waterUse); - map.set(INDICATOR_NAME_CODES.WATER_QUALITY, waterQuality); - map.set(INDICATOR_NAME_CODES.LAND_USE, landUse); - map.set( - INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION, - rawData.satDeforestation, - ); - map.set( - INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION_RISK, - rawData.satDeforestationRisk, - ); + map.set(INDICATOR_NAME_CODES.LF, landUse); + map.set(INDICATOR_NAME_CODES.DF_SLUC, deforestation); + map.set(INDICATOR_NAME_CODES.GHG_DEF_SLUC, climateRisk); + map.set(INDICATOR_NAME_CODES.GHG_FARM, naturalRisk); + map.set(INDICATOR_NAME_CODES.UWU, unsustainableWaterUse); + map.set(INDICATOR_NAME_CODES.WU, waterUse); + map.set(INDICATOR_NAME_CODES.WU, waterQuality); + map.set(INDICATOR_NAME_CODES.NL, naturalRisk); + map.set(INDICATOR_NAME_CODES.ENL, naturalRisk); + map.set(INDICATOR_NAME_CODES.NCE, naturalRisk); return map; } diff --git a/api/src/modules/indicators/indicator.entity.ts b/api/src/modules/indicators/indicator.entity.ts index d60de09270..cab80092fb 100644 --- a/api/src/modules/indicators/indicator.entity.ts +++ b/api/src/modules/indicators/indicator.entity.ts @@ -20,15 +20,15 @@ export enum INDICATOR_STATUS { } export enum INDICATOR_NAME_CODES { - LAND_USE = 'LI', - DEFORESTATION_RISK = 'DF_LUC_T', - CLIMATE_RISK = 'GHG_LUC_T', - WATER_USE = 'UWU_T', - UNSUSTAINABLE_WATER_USE = 'UWUSR_T', - NATURAL_ECOSYSTEM_CONVERSION_RISK = 'NECR', - WATER_QUALITY = 'WQ', - SATELLIGENCE_DEFORESTATION = 'SAT_DF', - SATELLIGENCE_DEFORESTATION_RISK = 'SAT_DF_R', + LF = 'LF', + DF_SLUC = 'DF_SLUC', + GHG_DEF_SLUC = 'GHG_DEF_SLUC', + WU = 'WU', + UWU = 'UWU', + NL = 'NL', + GHG_FARM = 'GHG_FARM', + ENL = 'ENL', + NCE = 'NCE', } export const indicatorResource: BaseServiceResource = { diff --git a/api/src/modules/indicators/indicators.service.ts b/api/src/modules/indicators/indicators.service.ts index aa29a9f303..3dcd40978d 100644 --- a/api/src/modules/indicators/indicators.service.ts +++ b/api/src/modules/indicators/indicators.service.ts @@ -83,7 +83,7 @@ export class IndicatorsService extends AppBaseService< const deforestationIndicator: Indicator | null = await this.indicatorRepository.findOne({ - where: { nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK }, + where: { nameCode: INDICATOR_NAME_CODES.DF_SLUC }, }); if (!deforestationIndicator) throw new NotFoundException( diff --git a/api/test/e2e/authorization/authorization.spec.ts b/api/test/e2e/authorization/authorization.spec.ts index 2a5ac03aa2..e18c051768 100644 --- a/api/test/e2e/authorization/authorization.spec.ts +++ b/api/test/e2e/authorization/authorization.spec.ts @@ -83,7 +83,7 @@ describe('Authorization Test (E2E)', () => { .expect(HttpStatus.OK); const indicator = await createIndicator({ - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); await request(testApplication.getHttpServer()) @@ -101,7 +101,7 @@ describe('Authorization Test (E2E)', () => { .expect(HttpStatus.FORBIDDEN); const indicator = await createIndicator({ - nameCode: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, + nameCode: INDICATOR_NAME_CODES.UWU, }); await request(testApplication.getHttpServer()) diff --git a/api/test/e2e/impact/impact-chart/chart.spec.ts b/api/test/e2e/impact/impact-chart/chart.spec.ts index 4f386d1873..f01fcc03d7 100644 --- a/api/test/e2e/impact/impact-chart/chart.spec.ts +++ b/api/test/e2e/impact/impact-chart/chart.spec.ts @@ -152,13 +152,13 @@ describe('Impact Chart (Ranking) Test Suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const indicator2: Indicator = await createIndicator({ name: 'Fake Indicator 2', unit, - nameCode: INDICATOR_NAME_CODES.CLIMATE_RISK, + nameCode: INDICATOR_NAME_CODES.GHG_DEF_SLUC, }); const businessUnit: BusinessUnit = await createBusinessUnit({ @@ -359,7 +359,7 @@ describe('Impact Chart (Ranking) Test Suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const businessUnit: BusinessUnit = await createBusinessUnit({ diff --git a/api/test/e2e/impact/impact-table/impact.spec.ts b/api/test/e2e/impact/impact-table/impact.spec.ts index 696ea9a9fa..f1d041155d 100644 --- a/api/test/e2e/impact/impact-table/impact.spec.ts +++ b/api/test/e2e/impact/impact-table/impact.spec.ts @@ -138,7 +138,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, status: INDICATOR_STATUS.ACTIVE, }); @@ -204,7 +204,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const businessUnit: BusinessUnit = await createBusinessUnit({ @@ -334,7 +334,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const businessUnit: BusinessUnit = await createBusinessUnit({ @@ -392,7 +392,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const businessUnit: BusinessUnit = await createBusinessUnit({ @@ -551,7 +551,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const parentMaterial1 = await createMaterial({ @@ -645,7 +645,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const material1: Material = await createMaterial({ @@ -755,7 +755,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const parentMaterial: Material = await createMaterial({ @@ -905,7 +905,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const material: Material = await createMaterial({ @@ -991,7 +991,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const material: Material = await createMaterial({ @@ -1102,7 +1102,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const material: Material = await createMaterial({ @@ -1196,7 +1196,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const material: Material = await createMaterial({ @@ -1297,7 +1297,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const material1: Material = await createMaterial({ @@ -1417,7 +1417,7 @@ describe('Impact Table and Charts test suite (e2e)', () => { const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const material: Material = await createMaterial({ diff --git a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/mixed-interventions-scenario.preconditions.ts b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/mixed-interventions-scenario.preconditions.ts index 7855b6fbd0..4ee730a356 100644 --- a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/mixed-interventions-scenario.preconditions.ts +++ b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/mixed-interventions-scenario.preconditions.ts @@ -41,7 +41,7 @@ export async function createMultipleInterventionsPreconditions(): Promise<{ const indicator: Indicator = await createIndicator({ name: 'Deforestation', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const textile: Material = await createMaterial({ name: 'Textile' }); diff --git a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-coefficients-intervention.preconditions.ts b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-coefficients-intervention.preconditions.ts index 6198c1752b..43307a6a68 100644 --- a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-coefficients-intervention.preconditions.ts +++ b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-coefficients-intervention.preconditions.ts @@ -47,7 +47,7 @@ export async function createNewCoefficientsInterventionPreconditions( const indicator: Indicator = await createIndicator({ name: 'Deforestation', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); // Creating Materials diff --git a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-material-intervention.preconditions.ts b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-material-intervention.preconditions.ts index 77aa12cbec..dac031a4c7 100644 --- a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-material-intervention.preconditions.ts +++ b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-material-intervention.preconditions.ts @@ -46,7 +46,7 @@ export async function createNewMaterialInterventionPreconditions( : await createIndicator({ name: 'Deforestation', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const textile: Material = await createMaterial({ name: 'Textile' }); diff --git a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-supplier-intervention.preconditions.ts b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-supplier-intervention.preconditions.ts index 94459d9c62..ae473e389e 100644 --- a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-supplier-intervention.preconditions.ts +++ b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/new-supplier-intervention.preconditions.ts @@ -48,7 +48,7 @@ export async function createNewSupplierInterventionPreconditions( : await createIndicator({ name: 'Deforestation', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const textile: Material = customMaterials diff --git a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/two-scenarios.preconditions.ts b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/two-scenarios.preconditions.ts index 0daf6c39cc..b98f275741 100644 --- a/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/two-scenarios.preconditions.ts +++ b/api/test/e2e/impact/mocks/actual-vs-scenario-preconditions/two-scenarios.preconditions.ts @@ -30,7 +30,7 @@ export async function createTwoScenariosPreconditions(): Promise<{ name: 'Deforestation', shortName: 'Deforestation', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const textile: Material = await createMaterial({ name: 'Textile' }); diff --git a/api/test/e2e/impact/mocks/scenario-vs-scenario-preconditions/mixed-scenarios.preconditions.ts b/api/test/e2e/impact/mocks/scenario-vs-scenario-preconditions/mixed-scenarios.preconditions.ts index 5c44ae4d37..48573b517a 100644 --- a/api/test/e2e/impact/mocks/scenario-vs-scenario-preconditions/mixed-scenarios.preconditions.ts +++ b/api/test/e2e/impact/mocks/scenario-vs-scenario-preconditions/mixed-scenarios.preconditions.ts @@ -41,7 +41,7 @@ export async function createMixedScenariosPreconditions(): Promise<{ const indicator: Indicator = await createIndicator({ name: 'Deforestation', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const textile: Material = await createMaterial({ name: 'Textile' }); diff --git a/api/test/e2e/impact/mocks/scenario-vs-scenario-preconditions/same-materials-scenarios.preconditions.ts b/api/test/e2e/impact/mocks/scenario-vs-scenario-preconditions/same-materials-scenarios.preconditions.ts index b14232645a..a418e1fd3f 100644 --- a/api/test/e2e/impact/mocks/scenario-vs-scenario-preconditions/same-materials-scenarios.preconditions.ts +++ b/api/test/e2e/impact/mocks/scenario-vs-scenario-preconditions/same-materials-scenarios.preconditions.ts @@ -42,7 +42,7 @@ export async function createSameMaterialScenariosPreconditions(): Promise<{ const indicator: Indicator = await createIndicator({ name: 'Deforestation', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const textile: Material = await createMaterial({ name: 'Textile' }); diff --git a/api/test/e2e/impact/mocks/sorting.preconditions.ts b/api/test/e2e/impact/mocks/sorting.preconditions.ts index 15b3cd1b6b..1d696551a8 100644 --- a/api/test/e2e/impact/mocks/sorting.preconditions.ts +++ b/api/test/e2e/impact/mocks/sorting.preconditions.ts @@ -41,7 +41,7 @@ export async function createImpactTableSortingPreconditions( const indicator: Indicator = await createIndicator({ name: 'Fake Indicator', unit, - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const parentMaterial1 = await createMaterial({ diff --git a/api/test/e2e/indicators/indicators.spec.ts b/api/test/e2e/indicators/indicators.spec.ts index 6605d998c0..79010296cd 100644 --- a/api/test/e2e/indicators/indicators.spec.ts +++ b/api/test/e2e/indicators/indicators.spec.ts @@ -51,7 +51,7 @@ describe('IndicatorsModule (e2e)', () => { .set('Authorization', `Bearer ${jwtToken}`) .send({ name: 'test indicator', - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }) .expect(HttpStatus.CREATED); diff --git a/api/test/e2e/scenario-interventions/location-types.spec.ts b/api/test/e2e/scenario-interventions/location-types.spec.ts index 453633bba3..4009142770 100644 --- a/api/test/e2e/scenario-interventions/location-types.spec.ts +++ b/api/test/e2e/scenario-interventions/location-types.spec.ts @@ -66,8 +66,8 @@ describe('Interventions E2E Tests (Location Types)', () => { 'Then I should get an error', async () => { await createIndicator({ - name: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, - nameCode: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, + name: INDICATOR_NAME_CODES.UWU, + nameCode: INDICATOR_NAME_CODES.UWU, status: INDICATOR_STATUS.ACTIVE, }); const response = await request(testApplication.getHttpServer()) @@ -86,7 +86,7 @@ describe('Interventions E2E Tests (Location Types)', () => { newLocationType: LOCATION_TYPES.ADMINISTRATIVE_REGION_OF_PRODUCTION, type: SCENARIO_INTERVENTION_TYPE.NEW_MATERIAL, newIndicatorCoefficients: { - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: 1, + [INDICATOR_NAME_CODES.UWU]: 1, }, }); diff --git a/api/test/e2e/scenario-interventions/validations/intervention-validations.spec.ts b/api/test/e2e/scenario-interventions/validations/intervention-validations.spec.ts index c517f592f7..a8a39a764a 100644 --- a/api/test/e2e/scenario-interventions/validations/intervention-validations.spec.ts +++ b/api/test/e2e/scenario-interventions/validations/intervention-validations.spec.ts @@ -120,7 +120,7 @@ describe('Interventions E2E Tests (Controller Validations)', () => { newLocationCountryInput: 'TestCountry', type: SCENARIO_INTERVENTION_TYPE.CHANGE_PRODUCTION_EFFICIENCY, newIndicatorCoefficients: { - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: 1, + [INDICATOR_NAME_CODES.UWU]: 1, }, }); @@ -139,12 +139,12 @@ describe('Interventions E2E Tests (Controller Validations)', () => { 'Then the validation should pass', async () => { await createIndicator({ - nameCode: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, - name: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, + nameCode: INDICATOR_NAME_CODES.UWU, + name: INDICATOR_NAME_CODES.UWU, }); await createIndicator({ - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, - name: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, + name: INDICATOR_NAME_CODES.DF_SLUC, }); const response = await request(testApplication.getHttpServer()) @@ -162,8 +162,8 @@ describe('Interventions E2E Tests (Controller Validations)', () => { newLocationCountryInput: 'TestCountry', type: SCENARIO_INTERVENTION_TYPE.CHANGE_PRODUCTION_EFFICIENCY, newIndicatorCoefficients: { - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: 1, - [INDICATOR_NAME_CODES.DEFORESTATION_RISK]: 2, + [INDICATOR_NAME_CODES.UWU]: 1, + [INDICATOR_NAME_CODES.DF_SLUC]: 2, }, }); @@ -178,12 +178,12 @@ describe('Interventions E2E Tests (Controller Validations)', () => { async () => { const intervention = await createScenarioIntervention(); await createIndicator({ - nameCode: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, - name: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, + nameCode: INDICATOR_NAME_CODES.UWU, + name: INDICATOR_NAME_CODES.UWU, }); await createIndicator({ - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, - name: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, + name: INDICATOR_NAME_CODES.DF_SLUC, }); const response = await request(testApplication.getHttpServer()) @@ -201,8 +201,8 @@ describe('Interventions E2E Tests (Controller Validations)', () => { newLocationCountryInput: 'TestCountry', type: SCENARIO_INTERVENTION_TYPE.CHANGE_PRODUCTION_EFFICIENCY, newIndicatorCoefficients: { - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: 1, - [INDICATOR_NAME_CODES.DEFORESTATION_RISK]: 2, + [INDICATOR_NAME_CODES.UWU]: 1, + [INDICATOR_NAME_CODES.DF_SLUC]: 2, }, }); @@ -216,12 +216,12 @@ describe('Interventions E2E Tests (Controller Validations)', () => { async () => { const intervention = await createScenarioIntervention(); await createIndicator({ - nameCode: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, - name: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, + nameCode: INDICATOR_NAME_CODES.UWU, + name: INDICATOR_NAME_CODES.UWU, }); await createIndicator({ - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, - name: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, + name: INDICATOR_NAME_CODES.DF_SLUC, }); const response = await request(testApplication.getHttpServer()) @@ -239,8 +239,8 @@ describe('Interventions E2E Tests (Controller Validations)', () => { newLocationCountryInput: 'TestCountry', type: SCENARIO_INTERVENTION_TYPE.CHANGE_PRODUCTION_EFFICIENCY, newIndicatorCoefficients: { - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: 1, - [INDICATOR_NAME_CODES.DEFORESTATION_RISK]: 2, + [INDICATOR_NAME_CODES.UWU]: 1, + [INDICATOR_NAME_CODES.DF_SLUC]: 2, }, }); @@ -306,7 +306,7 @@ describe('Interventions E2E Tests (Controller Validations)', () => { newLocationCountryInput: 'TestCountry', type: SCENARIO_INTERVENTION_TYPE.CHANGE_PRODUCTION_EFFICIENCY, newIndicatorCoefficients: { - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: 1, + [INDICATOR_NAME_CODES.UWU]: 1, }, }); diff --git a/api/test/integration/import-data/xlsx-uploads/import-mocks.ts b/api/test/integration/import-data/xlsx-uploads/import-mocks.ts index f9708c1fd4..a9b5cfcf61 100644 --- a/api/test/integration/import-data/xlsx-uploads/import-mocks.ts +++ b/api/test/integration/import-data/xlsx-uploads/import-mocks.ts @@ -21,19 +21,19 @@ async function createIndicatorsForXLSXImport( const indicatorSpec = [ { name: 'Deforestation loss due to land use change', - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }, { name: 'Carbon emissions due to land use change', - nameCode: INDICATOR_NAME_CODES.CLIMATE_RISK, + nameCode: INDICATOR_NAME_CODES.GHG_DEF_SLUC, }, { name: 'Biodiversity loss due to land use change', - nameCode: INDICATOR_NAME_CODES.LAND_USE, + nameCode: INDICATOR_NAME_CODES.LF, }, { name: 'Unsustainable water use', - nameCode: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, + nameCode: INDICATOR_NAME_CODES.UWU, }, ]; diff --git a/api/test/integration/indicator-record/calculations/indicator-records.service.spec.ts b/api/test/integration/indicator-record/calculations/indicator-records.service.spec.ts index bf07dc9548..45b6f51594 100644 --- a/api/test/integration/indicator-record/calculations/indicator-records.service.spec.ts +++ b/api/test/integration/indicator-record/calculations/indicator-records.service.spec.ts @@ -182,9 +182,9 @@ describe('Impact Calculator Tests', () => { }; const providedCoefficients: IndicatorCoefficientsDto = { - [INDICATOR_NAME_CODES.WATER_USE]: 0.1, - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: 0.4, - [INDICATOR_NAME_CODES.DEFORESTATION_RISK]: 0.35, + [INDICATOR_NAME_CODES.WU]: 0.1, + [INDICATOR_NAME_CODES.UWU]: 0.4, + [INDICATOR_NAME_CODES.DF_SLUC]: 0.35, ...({} as any), }; @@ -199,7 +199,7 @@ describe('Impact Calculator Tests', () => { //ASSERT //await expect(testStatement).rejects.toThrow(NotFoundException); await expect(testStatement).rejects.toThrow( - `Required coefficient for indicator ${INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE} was not provided`, + `Required coefficient for indicator ${INDICATOR_NAME_CODES.UWU} was not provided`, ); }); @@ -237,15 +237,15 @@ describe('Impact Calculator Tests', () => { }; const providedCoefficients: IndicatorCoefficientsDto = { - [INDICATOR_NAME_CODES.CLIMATE_RISK]: 0.1, - [INDICATOR_NAME_CODES.DEFORESTATION_RISK]: 0.4, - [INDICATOR_NAME_CODES.LAND_USE]: 0.35, - [INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE]: 0.2, - [INDICATOR_NAME_CODES.WATER_USE]: 0.6, - [INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION]: 0.3, - [INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION_RISK]: 0.5, - [INDICATOR_NAME_CODES.NATURAL_ECOSYSTEM_CONVERSION_RISK]: 0.7, - [INDICATOR_NAME_CODES.WATER_QUALITY]: 0.8, + [INDICATOR_NAME_CODES.GHG_DEF_SLUC]: 0.1, + [INDICATOR_NAME_CODES.DF_SLUC]: 0.4, + [INDICATOR_NAME_CODES.LF]: 0.35, + [INDICATOR_NAME_CODES.UWU]: 0.2, + [INDICATOR_NAME_CODES.WU]: 0.6, + [INDICATOR_NAME_CODES.NL]: 0.7, + [INDICATOR_NAME_CODES.GHG_FARM]: 0.8, + [INDICATOR_NAME_CODES.ENL]: 0.9, + [INDICATOR_NAME_CODES.NCE]: 0.4, }; //ACT @@ -423,7 +423,7 @@ describe('Impact Calculator Tests', () => { //ASSERT await expect(testStatement).rejects.toThrow(NotFoundException); await expect(testStatement).rejects.toThrow( - `H3 Data of required Indicator of type ${INDICATOR_NAME_CODES.DEFORESTATION_RISK} missing for ${INDICATOR_NAME_CODES.DEFORESTATION_RISK} Indicator Record value calculations`, + `H3 Data of required Indicator of type ${INDICATOR_NAME_CODES.DF_SLUC} missing for ${INDICATOR_NAME_CODES.DF_SLUC} Indicator Record value calculations`, ); }); @@ -658,11 +658,11 @@ describe('Impact Calculator Tests', () => { //Prepare Cache Data const bioMap: Map = new Map(); bioMap.set( - INDICATOR_NAME_CODES.LAND_USE, + INDICATOR_NAME_CODES.LF, indicatorPreconditions.biodiversityLoss, ); bioMap.set( - INDICATOR_NAME_CODES.DEFORESTATION_RISK, + INDICATOR_NAME_CODES.DF_SLUC, indicatorPreconditions.deforestation, ); const materialsMap: Map = new Map(); @@ -671,7 +671,7 @@ describe('Impact Calculator Tests', () => { const bioCacheKey: any = generateIndicatorCacheKey( indicatorPreconditions.sourcingLocation2.geoRegionId, - INDICATOR_NAME_CODES.LAND_USE, + INDICATOR_NAME_CODES.LF, bioMap, materialsMap, ); @@ -1042,31 +1042,21 @@ describe('Impact Calculator Tests', () => { const h3Data = await createWorldToCalculateIndicatorRecords(dataSource); const climateRiskIndicator = h3Data.indicators.find( - (el: Indicator) => el.nameCode === INDICATOR_NAME_CODES.CLIMATE_RISK, + (el: Indicator) => el.nameCode === INDICATOR_NAME_CODES.GHG_DEF_SLUC, ); const landUseIndicator = h3Data.indicators.find( - (el: Indicator) => el.nameCode === INDICATOR_NAME_CODES.LAND_USE, + (el: Indicator) => el.nameCode === INDICATOR_NAME_CODES.LF, ); const deforestationIndicator = h3Data.indicators.find( - (el: Indicator) => - el.nameCode === INDICATOR_NAME_CODES.DEFORESTATION_RISK, + (el: Indicator) => el.nameCode === INDICATOR_NAME_CODES.DF_SLUC, ); const waterUseIndicator = h3Data.indicators.find( - (el: Indicator) => el.nameCode === INDICATOR_NAME_CODES.WATER_USE, + (el: Indicator) => el.nameCode === INDICATOR_NAME_CODES.WU, ); const unsustWaterUseIndicator = h3Data.indicators.find( - (el: Indicator) => - el.nameCode === INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, - ); - const satelligenceDeforestation = h3Data.indicators.find( - (el: Indicator) => - el.nameCode === INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION, - ); - const satelligenceDeforestationRisk = h3Data.indicators.find( - (el: Indicator) => - el.nameCode === INDICATOR_NAME_CODES.SATELLIGENCE_DEFORESTATION_RISK, + (el: Indicator) => el.nameCode === INDICATOR_NAME_CODES.UWU, ); return { material1, @@ -1088,8 +1078,6 @@ describe('Impact Calculator Tests', () => { deforestationIndicator, waterUseIndicator, unsustWaterUseIndicator, - satelligenceDeforestation, - satelligenceDeforestationRisk, tablesToDrop: h3Data.tablesToDrop, }; } diff --git a/api/test/utils/indicator-records-preconditions.ts b/api/test/utils/indicator-records-preconditions.ts index ec31e6c953..9aff7e22ee 100644 --- a/api/test/utils/indicator-records-preconditions.ts +++ b/api/test/utils/indicator-records-preconditions.ts @@ -18,7 +18,7 @@ export const createWorldToCalculateIndicatorRecords = async ( // Creating Indicators: const climateRisk: Indicator = await createIndicator({ name: 'climate risk', - nameCode: INDICATOR_NAME_CODES.CLIMATE_RISK, + nameCode: INDICATOR_NAME_CODES.GHG_DEF_SLUC, }); const waterUse: Indicator = await createIndicator({ name: 'water use', @@ -26,16 +26,16 @@ export const createWorldToCalculateIndicatorRecords = async ( }); const unsustainableWaterUse: Indicator = await createIndicator({ name: 'unsust water use', - nameCode: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, + nameCode: INDICATOR_NAME_CODES.UWU, }); const deforestation: Indicator = await createIndicator({ name: 'def risk', - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); const landUse: Indicator = await createIndicator({ name: 'land use', - nameCode: INDICATOR_NAME_CODES.LAND_USE, + nameCode: INDICATOR_NAME_CODES.LF, }); // Creating tables with h3Data for the new indicators diff --git a/api/test/utils/scenario-interventions-preconditions.ts b/api/test/utils/scenario-interventions-preconditions.ts index 051e5971aa..577ef25c0d 100644 --- a/api/test/utils/scenario-interventions-preconditions.ts +++ b/api/test/utils/scenario-interventions-preconditions.ts @@ -94,24 +94,24 @@ export async function createInterventionPreconditions( const indicator1: Indicator = await createIndicator({ name: 'climate risk', - nameCode: INDICATOR_NAME_CODES.CLIMATE_RISK, + nameCode: INDICATOR_NAME_CODES.GHG_DEF_SLUC, }); const indicator2: Indicator = await createIndicator({ name: 'water use', - nameCode: INDICATOR_NAME_CODES.WATER_USE, + nameCode: INDICATOR_NAME_CODES.WU, }); const indicator3: Indicator = await createIndicator({ name: 'unsust water use', - nameCode: INDICATOR_NAME_CODES.UNSUSTAINABLE_WATER_USE, + nameCode: INDICATOR_NAME_CODES.UWU, }); const indicator4: Indicator = await createIndicator({ name: 'def risk', - nameCode: INDICATOR_NAME_CODES.DEFORESTATION_RISK, + nameCode: INDICATOR_NAME_CODES.DF_SLUC, }); await createIndicator({ name: 'land use', - nameCode: INDICATOR_NAME_CODES.LAND_USE, + nameCode: INDICATOR_NAME_CODES.LF, }); // Creating tables with h3Data for the new indicators