diff --git a/api/src/migrations/1695954091382-AddNewImpactStoredProcedure.ts b/api/src/migrations/1695954091382-AddNewImpactStoredProcedure.ts index bc4caafa7f..29c92543c6 100644 --- a/api/src/migrations/1695954091382-AddNewImpactStoredProcedure.ts +++ b/api/src/migrations/1695954091382-AddNewImpactStoredProcedure.ts @@ -1,5 +1,5 @@ import { - get_annual_commodity_weighted_impact_over_georegion, + get_annual_landscape_impact_over_georegion, get_h3_table_column_for_indicators_by_name_code, } from 'procedures/stored-prodecures'; import { MigrationInterface, QueryRunner } from 'typeorm'; @@ -10,7 +10,7 @@ export class AddNewImpactStoredProcedure1695954091382 public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(` - CREATE OR REPLACE FUNCTION ${get_annual_commodity_weighted_impact_over_georegion}( + CREATE OR REPLACE FUNCTION ${get_annual_landscape_impact_over_georegion}( geo_region_id uuid, shortName text, material_id uuid, 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 af4e5dea8b..b852f4e4d4 100644 --- a/api/src/modules/indicator-records/services/impact-calculation.dependencies.ts +++ b/api/src/modules/indicator-records/services/impact-calculation.dependencies.ts @@ -1,6 +1,6 @@ import { INDICATOR_NAME_CODES } from 'modules/indicators/indicator.entity'; import { - get_annual_commodity_weighted_impact_over_georegion, + get_annual_landscape_impact_over_georegion, get_indicator_coefficient_impact, } from 'procedures/stored-prodecures'; @@ -74,17 +74,17 @@ export const INDICATOR_NAME_CODE_TO_QUERY_MAP: { production: () => `sum_material_over_georegion($1, $2, 'producer') as "${QueryPropertyNames.production}"`, [INDICATOR_NAME_CODES.DF_SLUC]: (nameCode: INDICATOR_NAME_CODES) => - `${get_annual_commodity_weighted_impact_over_georegion}($1, '${nameCode}', $2, 'producer') as "${INDICATOR_NAME_CODES.DF_SLUC}"`, + `${get_annual_landscape_impact_over_georegion}($1, '${nameCode}', $2, 'producer') as "${INDICATOR_NAME_CODES.DF_SLUC}"`, }, [INDICATOR_NAME_CODES.GHG_DEF_SLUC]: { production: () => `sum_material_over_georegion($1, $2, 'producer') as "${QueryPropertyNames.production}"`, [INDICATOR_NAME_CODES.GHG_DEF_SLUC]: (nameCode: INDICATOR_NAME_CODES) => - `${get_annual_commodity_weighted_impact_over_georegion}($1,'${nameCode}', $2, 'producer') as "${INDICATOR_NAME_CODES.GHG_DEF_SLUC}"`, + `${get_annual_landscape_impact_over_georegion}($1,'${nameCode}', $2, 'producer') as "${INDICATOR_NAME_CODES.GHG_DEF_SLUC}"`, }, [INDICATOR_NAME_CODES.UWU]: { [INDICATOR_NAME_CODES.UWU]: (nameCode: INDICATOR_NAME_CODES) => - `${get_annual_commodity_weighted_impact_over_georegion}($1, '${nameCode}', $2, 'producer') as "${INDICATOR_NAME_CODES.UWU}"`, + `${get_indicator_coefficient_impact}('${nameCode}', $3, $2) as "${INDICATOR_NAME_CODES.UWU}"`, }, [INDICATOR_NAME_CODES.WU]: { [INDICATOR_NAME_CODES.WU]: (nameCode: INDICATOR_NAME_CODES) => @@ -99,7 +99,7 @@ export const INDICATOR_NAME_CODE_TO_QUERY_MAP: { production: () => `sum_material_over_georegion($1, $2, 'producer') as "${QueryPropertyNames.production}"`, [INDICATOR_NAME_CODES.NCE]: (nameCode: INDICATOR_NAME_CODES) => - `${get_annual_commodity_weighted_impact_over_georegion}($1, '${nameCode}', $2, 'producer') as "${INDICATOR_NAME_CODES.NCE}"`, + `${get_annual_landscape_impact_over_georegion}($1, '${nameCode}', $2, 'producer') as "${INDICATOR_NAME_CODES.NCE}"`, }, [INDICATOR_NAME_CODES.FLIL]: { production: () => @@ -107,6 +107,6 @@ export const INDICATOR_NAME_CODE_TO_QUERY_MAP: { harvest: () => `sum_material_over_georegion($1, $2, 'harvest') as "${QueryPropertyNames.harvest}"`, [INDICATOR_NAME_CODES.FLIL]: (nameCode: INDICATOR_NAME_CODES) => - `${get_annual_commodity_weighted_impact_over_georegion}($1, '${nameCode}', $2, 'producer') as "${INDICATOR_NAME_CODES.FLIL}"`, + `${get_annual_landscape_impact_over_georegion}($1, '${nameCode}', $2, 'producer') as "${INDICATOR_NAME_CODES.FLIL}"`, }, }; diff --git a/api/src/procedures/stored-prodecures.ts b/api/src/procedures/stored-prodecures.ts index c1e7e0c564..9258aa95aa 100644 --- a/api/src/procedures/stored-prodecures.ts +++ b/api/src/procedures/stored-prodecures.ts @@ -1,6 +1,6 @@ export const get_h3_table_column_for_indicators_by_name_code: string = 'get_h3_table_column_for_indicators_by_name_code'; -export const get_annual_commodity_weighted_impact_over_georegion: string = `get_annual_commodity_weighted_impact_over_georegion`; +export const get_annual_landscape_impact_over_georegion: string = `get_annual_landscape_impact_over_georegion`; export const get_indicator_coefficient_impact: string = `get_indicator_coefficient_impact`;