Skip to content

Commit

Permalink
Merge pull request #23 from globalfund/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
stephanoshadjipetrou authored Jul 15, 2024
2 parents 1b644e9 + 403bf25 commit 9d65a74
Show file tree
Hide file tree
Showing 138 changed files with 11,607 additions and 12,318 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dist
*.json
# *.json
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"editor.trimAutoWhitespace": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.eslint": true
"source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit"
},

"files.exclude": {
Expand Down
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:16.19.1-alpine3.17

# For development add /bin/bash
RUN apk update && apk add --no-cache bash

# Set up the server directory
WORKDIR /app
COPY . /app

# Install yarn dependencies
RUN yarn install --network-timeout 100000
RUN yarn build

# Install yarn dependencies
RUN yarn global add pm2
RUN yarn install
RUN yarn build

# APP LOG DIRECTORY FROM pm2.config.js
RUN mkdir -p /home/zim/app-logs/the-data-explorer-api

# Run `yarn docker` to build, migrate and run the server with pm2.
CMD ["yarn", "docker"]
15 changes: 15 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:16.19.1-alpine3.17

# For development add /bin/bash
RUN apk update && apk add --no-cache bash

# Set up the server directory
WORKDIR /app
COPY . /app

# Install yarn dependencies
RUN yarn install --network-timeout 100000
RUN yarn build

# Run `yarn docker` to build, migrate and run the server with pm2.
CMD ["yarn", "dev"]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"clean": "lb-clean dist *.tsbuildinfo .eslintcache",
"rebuild": "yarn run clean && yarn run build",
"dev": "nodemon server.js",
"deploy": "yarn prestart && pm2 start pm2.config.js --env production"
"deploy": "yarn prestart && pm2 start pm2.config.js --env production",
"docker": "yarn prestart && pm2-runtime start pm2.config.js --env production"
},
"nodemonConfig": {
"verbose": true,
Expand Down
2 changes: 2 additions & 0 deletions src/config/filtering/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
"or_operator": "OR",
"eq": " eq ",
"in": " in ",
"gte": " ge ",
"lte": " le ",
"multi_param_separator": ","
}
8 changes: 8 additions & 0 deletions src/config/mapping/allocations/cumulative-by-cycles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dataPath": "value",
"value": "value",
"cycle": "periodCovered",
"component": "activityArea.name",
"colors": ["#0A2840", "#013E77", "#00B5AE", "#C3EDFD", "#D9D9D9"],
"urlParams": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate'<filterString>)/groupby((periodCovered,activityArea/name),aggregate(actualAmount with sum as value))"
}
6 changes: 6 additions & 0 deletions src/config/mapping/allocations/cycles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dataPath": "value",
"cycleFrom": "periodCovered",
"cycleTo": "",
"urlParams": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate'<filterString>)/groupby((periodCovered))&$orderby=periodCovered asc"
}
12 changes: 12 additions & 0 deletions src/config/mapping/allocations/radial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"dataPath": "value",
"cycle": "periodFrom",
"name": "activityArea.name",
"tooltipItem": "geography.parent.parent.name",
"value": "value",
"countryCode": "geography/code",
"urlParams": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate'<filterString>)/groupby((activityArea/name,geography/parent/parent/name),aggregate(actualAmount with sum as value))",
"urlParamsLocation": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate'<filterString>)/groupby((activityArea/name),aggregate(actualAmount with sum as value))",
"countriesCountUrlParams": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate'<filterString>)/groupby((geography/name))",
"colors": ["#0A2840", "#013E77", "#00B5AE", "#C3EDFD"]
}
7 changes: 7 additions & 0 deletions src/config/mapping/allocations/sunburst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dataPath": "value",
"value": "value",
"region": "geography.parent.name",
"country": "geography.name",
"urlParams": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate'<filterString>)/groupby((geography/parent/name,geography/name),aggregate(actualAmount with sum as value))"
}
8 changes: 8 additions & 0 deletions src/config/mapping/allocations/table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dataPath": "value",
"value": "value",
"cycle": "periodCovered",
"component": "activityArea.name",
"geography": "geography.name",
"urlParams": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate'<filterString>)/groupby((activityArea/name,geography/name,periodCovered),aggregate(actualAmount with sum as value))"
}
37 changes: 37 additions & 0 deletions src/config/mapping/allocations/treemap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"dataPath": "value",
"value": "value",
"component": "activityArea.name",
"geography": "geography.name",
"colors": [
{
"bg": "#0A2840",
"text": "#FFFFFF",
"items": "#164366"
},
{
"bg": "#013E77",
"text": "#FFFFFF",
"items": "#0B5191"
},
{
"bg": "#00B5AE",
"text": "#000000",
"items": "#18CCC5"
},
{
"bg": "#C3EDFD",
"text": "#FFFFFF",
"items": "#B3D7E5"
},
{
"bg": "#F3F5F4",
"text": "#FFFFFF",
"items": "#DDDDDD"
}
],
"urlParams": [
"?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate'<filterString>)/groupby((activityArea/name),aggregate(actualAmount with sum as value))",
"?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate'<filterString>)/groupby((activityArea/name,geography/name),aggregate(actualAmount with sum as value))"
]
}
8 changes: 8 additions & 0 deletions src/config/mapping/budgets/breakdown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dataPath": "value",
"name": "implementationPeriod.grant.<componentField>.name",
"value": "value",
"urlParams1": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'GrantBudget_ReferenceRate'<filterString>)/groupby((implementationPeriod/grant/<componentField>/name),aggregate(plannedAmount with sum as value))",
"urlParams2": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'GrantBudget_ReferenceRate'<filterString>)/groupby((implementationPeriod/grant/<componentField>/parent/name),aggregate(plannedAmount with sum as value))",
"colors": ["#0A2840", "#013E77", "#00B5AE", "#10708F", "#C3EDFD", "#F3F5F4"]
}
7 changes: 7 additions & 0 deletions src/config/mapping/budgets/cycles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dataPath": "value",
"cycleFrom": "implementationPeriod.periodFrom",
"cycleTo": "implementationPeriod.periodTo",
"urlParams": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'GrantBudget_ReferenceRate'<filterString>)/groupby((implementationPeriod/periodFrom,implementationPeriod/periodTo))&$orderby=implementationPeriod/periodFrom asc",
"urlParamsMetrics": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'ImplementationPeriodFinancialMetricAmount'<filterString>)/groupby((implementationPeriod/periodFrom,implementationPeriod/periodTo))&$orderby=implementationPeriod/periodFrom asc"
}
17 changes: 17 additions & 0 deletions src/config/mapping/budgets/metrics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"dataPath": "value",
"indicatorNameField": "indicatorName",
"expenditureIndicatorName": "Total Expenditure to Last Expenditure Reporting Period - Reference Rate",
"budgetIndicatorName": "Total Budget to Last Expenditure Reporting Period - Reference Rate",
"disbursementIndicatorName": "Total Disbursement to Last Expenditure Reporting Period - Reference Rate",
"cashBalanceIndicatorName": "Opening Cash Balance - Reference Rate",
"organisationName": "implementationPeriod.grant.principalRecipient.name",
"organisationSubType": "implementationPeriod.grant.principalRecipient.type.name",
"organisationType": "implementationPeriod.grant.principalRecipient.type.parent.name",
"expenditureValue": "actualCumulative",
"budgetValue": "plannedCumulative",
"disbursementValue": "actualCumulative",
"cashBalanceValue": "actual",
"urlParams": "?$apply=filter(financialDataSet eq 'ImplementationPeriodFinancialMetricAmount'<filterString>)/groupby((indicatorName),aggregate(actualAmount with sum as actual,actualAmountCumulative with sum as actualCumulative,plannedAmountCumulative with sum as plannedCumulative))",
"urlParamsOrganisations": "?$apply=filter(financialDataSet eq 'ImplementationPeriodFinancialMetricAmount'<filterString>)/groupby((indicatorName,implementationPeriod/grant/principalRecipient/type/parent/name,implementationPeriod/grant/principalRecipient/type/name,implementationPeriod/grant/principalRecipient/name),aggregate(actualAmount with sum as actual,actualAmountCumulative with sum as actualCumulative,plannedAmountCumulative with sum as plannedCumulative))"
}
7 changes: 7 additions & 0 deletions src/config/mapping/budgets/radial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dataPath": "value",
"name": "activityAreaGroup.parent.parent.name",
"value": "value",
"urlParams": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'GrantBudget_ReferenceRate'<filterString>)/groupby((activityAreaGroup/parent/parent/name),aggregate(plannedAmount with sum as value))",
"colors": ["#0A2840", "#013E77", "#00B5AE", "#C3EDFD", "#F3F5F4"]
}
10 changes: 10 additions & 0 deletions src/config/mapping/budgets/sankey.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dataPath": "value",
"level1Field": "financialCategory.parent.parent.name",
"level2Field": "financialCategory.parent.name",
"level3Field": "financialCategory.name",
"valueField": "value",
"cycle": "periodFrom",
"nodeColors": ["#252C34", "#252C34", "#252C34"],
"urlParams": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'GrantBudget_ReferenceRate'<filterString>)/groupby((financialCategory/name,financialCategory/parent/name,financialCategory/parent/parent/name),aggregate(plannedAmount with sum as value))"
}
12 changes: 12 additions & 0 deletions src/config/mapping/budgets/table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"dataPath": "value",
"level1Field": "financialCategory.parent.parent.name",
"level2Field": "financialCategory.parent.name",
"level3Field": "financialCategory.name",
"valueField": "value",
"cycle": "periodFrom",
"urlParams": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'GrantBudget_ReferenceRate'<filterString>)/groupby((financialCategory/name,financialCategory/parent/name,financialCategory/parent/parent/name),aggregate(plannedAmount with sum as value))",
"level1FieldVar2": "<componentField>.parent.name",
"level2FieldVar2": "<componentField>.name",
"urlParamsVar2": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'GrantBudget_ReferenceRate'<filterString>)/groupby((<componentField>/name,<componentField>/parent/name,<componentField>/parent/parent/name),aggregate(plannedAmount with sum as value))"
}
40 changes: 40 additions & 0 deletions src/config/mapping/budgets/treemap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"dataPath": "value",
"cycle": "periodFrom",
"name": "implementationPeriod.grant.<componentField>.name",
"value": "value",
"urlParams1": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'GrantBudget_ReferenceRate'<filterString>)/groupby((implementationPeriod/grant/<componentField>/name),aggregate(plannedAmount with sum as value))",
"urlParams2": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'GrantBudget_ReferenceRate'<filterString>)/groupby((implementationPeriod/grant/<componentField>/parent/name),aggregate(plannedAmount with sum as value))",
"url1Items": ["Malaria", "Tuberculosis"],
"url2Items": ["HIV/AIDS", "Other"],
"textbgcolors": [
{
"color": "#0A2840",
"textcolor": "#FFFFFF"
},
{
"color": "#013E77",
"textcolor": "#FFFFFF"
},
{
"color": "#00B5AE",
"textcolor": "#FFFFFF"
},
{
"color": "#10708F",
"textcolor": "#FFFFFF"
},
{
"color": "#9EDBE9",
"textcolor": "#000000"
},
{
"color": "#C3EDFD",
"textcolor": "#000000"
},
{
"color": "#F3F5F4",
"textcolor": "#000000"
}
]
}
10 changes: 10 additions & 0 deletions src/config/mapping/disbursements/barChart.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dataPath": "value",
"name": "implementationPeriod.grant.<componentField>.name",
"value": "value",
"urlParams1": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'Disbursement_ReferenceRate'<filterString>)/groupby((implementationPeriod/grant/<componentField>/name),aggregate(actualAmount with sum as value))&$orderby=value desc",
"urlParams2": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'Disbursement_ReferenceRate'<filterString>)/groupby((implementationPeriod/grant/<componentField>/parent/name),aggregate(actualAmount with sum as value))&$orderby=value desc",
"url1Items": ["Malaria", "Tuberculosis"],
"url2Items": ["HIV/AIDS", "Other"],
"barColor": "#013E77"
}
6 changes: 6 additions & 0 deletions src/config/mapping/disbursements/cycles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dataPath": "value",
"cycleFrom": "implementationPeriod.periodFrom",
"cycleTo": "implementationPeriod.periodTo",
"urlParams": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'Disbursement_ReferenceRate'<filterString>)/groupby((implementationPeriod/periodFrom,implementationPeriod/periodTo))&$orderby=implementationPeriod/periodFrom asc"
}
12 changes: 12 additions & 0 deletions src/config/mapping/disbursements/lineChart.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"dataPath": "value",
"count": "@odata.count",
"cycle": "periodFrom",
"value": "value",
"line": "implementationPeriod.grant.<componentField>.name",
"urlParams1": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'Disbursement_ReferenceRate'<filterString>)/groupby((periodFrom,implementationPeriod/grant/<componentField>/name),aggregate(actualAmount with sum as value))",
"urlParams2": "?$apply=filter(contains(indicatorName, 'reference') AND financialDataSet eq 'Disbursement_ReferenceRate'<filterString>)/groupby((periodFrom,implementationPeriod/grant/<componentField>/parent/name),aggregate(actualAmount with sum as value))",
"url1Items": ["Malaria", "Tuberculosis"],
"url2Items": ["HIV/AIDS", "Other"],
"colors": ["#0A2840", "#DEE1E7", "#013E77", "#00B5AE", "#C3EDFD", "#D9D9D9"]
}
14 changes: 14 additions & 0 deletions src/config/mapping/disbursements/table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dataPath": "value",
"indicatorField": "indicatorName",
"signedIndicator": "Total Signed Amount - Reference Rate",
"commitmentIndicator": "Total Commitment Amount - Reference Rate",
"disbursementIndicator": "Total Disbursed Amount - Reference Rate",
"component": "implementationPeriod.grant.<componentField>.name",
"grants": "count",
"valueField": "value",
"urlParams1": "?$apply=filter(indicatorName in ('Total Signed Amount - Reference Rate','Total Commitment Amount - Reference Rate','Total Disbursed Amount - Reference Rate')<filterString>)/groupby((implementationPeriod/grant/<componentField>/name,indicatorName),aggregate(actualAmount with sum as value,implementationPeriod/grantId with countdistinct as count))&$orderby=value desc",
"urlParams2": "?$apply=filter(indicatorName in ('Total Signed Amount - Reference Rate','Total Commitment Amount - Reference Rate','Total Disbursed Amount - Reference Rate')<filterString>)/groupby((implementationPeriod/grant/<componentField>/parent/name,indicatorName),aggregate(actualAmount with sum as value,implementationPeriod/grantId with countdistinct as count))&$orderby=value desc",
"url1Items": ["Malaria", "Tuberculosis"],
"url2Items": ["HIV/AIDS", "Other"]
}
9 changes: 9 additions & 0 deletions src/config/mapping/documents/list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dataPath": "value",
"type": "documentType.parent.name",
"subType": "documentType.name",
"title": "title",
"url": "url",
"geography": "geography.name",
"urlParams": "?$apply=filter(<filterString>)/groupby((geography/name,documentType/index,documentType/parent/name,documentType/name,title,url))&$orderby=documentType/index asc,title asc"
}
33 changes: 33 additions & 0 deletions src/config/mapping/eligibility/heatmap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"dataPath": "value",
"cycle": "fundingStream",
"incomeLevel": "incomeLevel",
"diseaseBurden": "diseaseBurden",
"isEligible": "isEligible",
"eligibilityYear": "eligibilityYear",
"component": "activityArea.name",
"urlParams": "?$select=fundingStream,incomeLevel,isEligible,diseaseBurden,eligibilityYear,geography,activityArea&$expand=activityArea&$filter=geography/code eq '<countryCode>'",
"isEligibleValueMapping": {
"true": "Eligible",
"false": "Not Eligible"
},
"incomeLevelValueMapping": {
"Lower middle income": "LM",
"Small Island income": "SI",
"Low income": "Low",
"Lower-Lower middle income": "LLM",
"Upper middle income": "UM",
"NA": "NA",
"High income": "High",
"Upper-Lower middle income": "ULM"
},
"diseaseBurdenValueMapping": {
"NA": "NA",
"Low": "L",
"Moderate": "M",
"High": "H",
"Severe": "S",
"Extreme": "E",
"Not High": "NH"
}
}
6 changes: 6 additions & 0 deletions src/config/mapping/eligibility/stats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dataPath": "value",
"geography": "geography.name",
"component": "activityArea.name",
"urlParams": "?$apply=filter(isEligible eq true<filterString>)/groupby((activityArea/name,geography/name))"
}
15 changes: 15 additions & 0 deletions src/config/mapping/eligibility/table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dataPath": "value",
"geography": "geography.name",
"year": "eligibilityYear",
"component": "activityArea.name",
"incomeLevel": "incomeLevel",
"diseaseBurden": "diseaseBurden",
"isEligible": "isEligible",
"eligibilityValues": {
"eligible": "Eligible",
"notEligible": "Not Eligible",
"transitionFunding": "Transition Funding"
},
"urlParams": "?$apply=filter(<filterString>)/groupby((geography/name,eligibilityYear,activityArea/name,isEligible,incomeLevel,diseaseBurden))&$orderby=geography/name,activityArea/name"
}
4 changes: 4 additions & 0 deletions src/config/mapping/expenditures/availability.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dataPath": "@odata.count",
"urlParams": "?$count=true&$top=0&$filter=financialDataSet eq 'Expenditure_Intervention_ReferenceRate' AND isLatestReported eq true<filterString>"
}
8 changes: 8 additions & 0 deletions src/config/mapping/expenditures/bar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dataPath": "value",
"name": "<componentField>.parent.name",
"itemName": "<componentField>.name",
"indicatorName": "indicatorName",
"value": "actual",
"urlParams": "?$apply=filter(indicatorName in ('Expenditure: Module-Intervention - Reference Rate') AND isLatestReported eq true<filterString>)/groupby((indicatorName,<componentField>/name,<componentField>/parent/name),aggregate(actualAmountCumulative with sum as actual))"
}
6 changes: 6 additions & 0 deletions src/config/mapping/expenditures/cycles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dataPath": "value",
"cycleFrom": "implementationPeriod.periodFrom",
"cycleTo": "implementationPeriod.periodTo",
"urlParams": "?$apply=filter(indicatorName eq 'Expenditure: Module-Intervention - Reference Rate' AND isLatestReported eq true<filterString>)/groupby((implementationPeriod/periodFrom,implementationPeriod/periodTo))&$orderby=implementationPeriod/periodFrom asc"
}
Loading

0 comments on commit 9d65a74

Please sign in to comment.