From 7c0ba002cd379dafe6b46cab7b28e6aed0587bfd Mon Sep 17 00:00:00 2001 From: Stefanos Hadjipetrou Date: Tue, 9 Jul 2024 17:09:26 +0300 Subject: [PATCH] feat: grant targets & results adjustments --- src/config/mapping/grants/targetsResults.json | 4 ++- src/controllers/grants.controller.ts | 31 +++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/config/mapping/grants/targetsResults.json b/src/config/mapping/grants/targetsResults.json index c5745af..e82c011 100644 --- a/src/config/mapping/grants/targetsResults.json +++ b/src/config/mapping/grants/targetsResults.json @@ -8,9 +8,11 @@ "baselineValue": "baselineValuePercentage", "baselineYear": "baselineValueYear", "baselineSource": "valueSource", + "startDate": "startDate", + "endDate": "endDate", "year": "targetValueYear", "target": "targetValuePercentage", "result": "resultValuePercentage", "achievement": "performance", - "urlParams": "?$filter=programmaticDataSet eq 'IMPLEMENTATION_PERIOD_TARGETS_RESULTS' AND implementationPeriod/code eq '' AND valueType eq ''&$expand=activityArea($select=name)&$select=activityArea,indicatorName,isReversed,geographicCoverage,aggregationType,baselineValuePercentage,baselineValueYear,valueSource,targetValueYear,targetValuePercentage,resultValuePercentage,performance" + "urlParams": "?$filter=programmaticDataSet eq 'IMPLEMENTATION_PERIOD_TARGETS_RESULTS' AND implementationPeriod/code eq '' AND valueType eq ''&$expand=activityArea($select=name)&$select=activityArea,indicatorName,isReversed,geographicCoverage,startDate,baselineValuePercentage,baselineValueYear,valueSource,targetValueYear,targetValuePercentage,resultValuePercentage,performance" } diff --git a/src/controllers/grants.controller.ts b/src/controllers/grants.controller.ts index d501172..473eee8 100644 --- a/src/controllers/grants.controller.ts +++ b/src/controllers/grants.controller.ts @@ -506,6 +506,9 @@ export class GrantsController { data.nodes.push({ name: category1, level: 1, + itemStyle: { + color: '#252C34', + }, }); data.links.push({ source: 'Total budget', @@ -530,6 +533,9 @@ export class GrantsController { data.nodes.push({ name, level: 2, + itemStyle: { + color: '#252C34', + }, }); data.links.push({ source: category1, @@ -564,6 +570,9 @@ export class GrantsController { data.nodes.push({ name, level: 3, + itemStyle: { + color: '#252C34', + }, }); data.links.push({ @@ -620,6 +629,14 @@ export class GrantsController { let years: string[] = []; + if (type === 'Coverage / Output indicator') { + _.forEach(raw, (item: any) => { + item.targetValueYear = moment( + _.get(item, GrantTargetsResultsMapping.startDate, ''), + ).get('year'); + }); + } + _.map(groupedByModule, (moduleItems, key) => { const item: any = { name: key, @@ -643,6 +660,10 @@ export class GrantsController { GrantTargetsResultsMapping.year, ); years = [...years, ...Object.keys(groupedByYear)]; + years = _.filter( + _.uniq(years), + year => year !== 'null' && year !== 'NaN', + ); let itempush = { reversed: _.get(item, GrantTargetsResultsMapping.reversed, false) === @@ -711,9 +732,13 @@ export class GrantsController { data.push(item); }); - years = _.uniq(years); - - return {data, years}; + return { + data: + type === 'Coverage / Output indicator' + ? data + : _.get(data, '[0]._children', []), + years, + }; }) .catch(handleDataApiError); }