Skip to content

Commit

Permalink
feat: grant targets & results adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Jul 9, 2024
1 parent 526d2ae commit 7c0ba00
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/config/mapping/grants/targetsResults.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<grantIP>' AND valueType eq '<type>'&$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 '<grantIP>' AND valueType eq '<type>'&$expand=activityArea($select=name)&$select=activityArea,indicatorName,isReversed,geographicCoverage,startDate,baselineValuePercentage,baselineValueYear,valueSource,targetValueYear,targetValuePercentage,resultValuePercentage,performance"
}
31 changes: 28 additions & 3 deletions src/controllers/grants.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@ export class GrantsController {
data.nodes.push({
name: category1,
level: 1,
itemStyle: {
color: '#252C34',
},
});
data.links.push({
source: 'Total budget',
Expand All @@ -530,6 +533,9 @@ export class GrantsController {
data.nodes.push({
name,
level: 2,
itemStyle: {
color: '#252C34',
},
});
data.links.push({
source: category1,
Expand Down Expand Up @@ -564,6 +570,9 @@ export class GrantsController {
data.nodes.push({
name,
level: 3,
itemStyle: {
color: '#252C34',
},
});

data.links.push({
Expand Down Expand Up @@ -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,
Expand All @@ -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) ===
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 7c0ba00

Please sign in to comment.