Skip to content

Commit

Permalink
feat: general optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Jul 12, 2024
1 parent 294d20f commit a7f557a
Show file tree
Hide file tree
Showing 11 changed files with 3,024 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/config/mapping/expenditures/availability.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"dataPath": "@odata.count",
"urlParams": "?$count=true&$top=0&$filter=financialDataSet eq 'Expenditure_Intervention_ReferenceRate' AND isAnnualized eq true<filterString>"
"urlParams": "?$count=true&$top=0&$filter=financialDataSet eq 'Expenditure_Intervention_ReferenceRate' AND isLatestReported eq true<filterString>"
}
2 changes: 1 addition & 1 deletion src/config/mapping/expenditures/bar.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"itemName": "<componentField>.name",
"indicatorName": "indicatorName",
"value": "actual",
"urlParams": "?$apply=filter(indicatorName in ('Expenditure: Module-Intervention - Reference Rate') AND isAnnualized eq true<filterString>)/groupby((indicatorName,<componentField>/name,<componentField>/parent/name),aggregate(actualAmount with sum as 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))"
}
2 changes: 1 addition & 1 deletion src/config/mapping/expenditures/cycles.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"dataPath": "value",
"cycleFrom": "implementationPeriod.periodFrom",
"cycleTo": "implementationPeriod.periodTo",
"urlParams": "?$apply=filter(indicatorName eq 'Expenditure: Module-Intervention - Reference Rate' AND isAnnualized eq true<filterString>)/groupby((implementationPeriod/periodFrom,implementationPeriod/periodTo))&$orderby=implementationPeriod/periodFrom asc"
"urlParams": "?$apply=filter(indicatorName eq 'Expenditure: Module-Intervention - Reference Rate' AND isLatestReported eq true<filterString>)/groupby((implementationPeriod/periodFrom,implementationPeriod/periodTo))&$orderby=implementationPeriod/periodFrom asc"
}
2 changes: 1 addition & 1 deletion src/config/mapping/expenditures/heatmap.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"budget": "value2",
"expenditure": "value1",
"cycle": "periodCovered",
"urlParams": "?$apply=filter(financialDataSet eq 'Expenditure_Intervention_ReferenceRate' AND isAnnualized eq true<filterString>)/groupby((<rowField>,<columnField>),aggregate(actualAmount with sum as value1,plannedAmount with sum as value2))",
"urlParams": "?$apply=filter(financialDataSet eq 'Expenditure_Intervention_ReferenceRate' AND isLatestReported eq true<filterString>)/groupby((<rowField>,<columnField>),aggregate(actualAmountCumulative with sum as value1,plannedAmountCumulative with sum as value2))",
"url1Items": ["Malaria", "Tuberculosis"],
"url2Items": ["HIV/AIDS", "Other"],
"fields": {
Expand Down
2 changes: 1 addition & 1 deletion src/config/mapping/expenditures/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"indicatorName": "indicatorName",
"cumulativeExpenditureValue": "actualCumulative",
"periodExpenditureValue": "actual",
"urlParams": "?$apply=filter(indicatorName in ('Expenditure: Module-Intervention - Reference Rate') AND isAnnualized eq true<filterString>)/groupby((indicatorName,<componentField>/name,<componentField>/parent/name),aggregate(actualAmountCumulative with sum as actualCumulative,actualAmount with sum as 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 actualCumulative,actualAmount with sum as actual))"
}
4 changes: 2 additions & 2 deletions src/config/urls/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"filteroptionsreplenishmentperiods": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/replenishmentperiods",
"multicountriescountriesdata": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/MultiCountries?$expand=MultiCountryComposition($select=GeographicArea;$expand=GeographicArea($select=GeographicAreaCode_ISO3))&$select=MultiCountryName,MultiCountryComposition",
"FILTER_OPTIONS_GEOGRAPHIES": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/Geographies?$filter=level eq 'World'&$expand=children($expand=children($expand=children))",
"FILTER_OPTIONS_GEOGRAPHIES_BOARD_CONSTITUENCY_VIEW": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/Geographies_BoardConstituencyView?&$expand=children($expand=children($expand=children))",
"FILTER_OPTIONS_GEOGRAPHIES_PORTFOLIO_VIEW": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/Geographies_PortfolioView?&$expand=children($expand=children($expand=children))",
"FILTER_OPTIONS_GEOGRAPHIES_BOARD_CONSTITUENCY_VIEW": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/Geographies_BoardConstituencyView?&$filter=parentId ne null AND children/any(c: c ne null)&$expand=children($expand=children($expand=children))",
"FILTER_OPTIONS_GEOGRAPHIES_PORTFOLIO_VIEW": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/Geographies_PortfolioView?&$filter=parentId ne null AND children/any(c: c ne null)&$expand=children($expand=children($expand=children))",
"FILTER_OPTIONS_COMPONENTS_GROUPED": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/ActivityAreasGrouped?$filter=parentId eq null",
"FILTER_OPTIONS_COMPONENTS_UNGROUPED": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/ActivityAreas?$filter=type eq 'Component'",
"FILTER_OPTIONS_REPLENISHMENT_PERIODS": "https://api-gf-api-gf-02.azurewebsites.net/v4/odata/allFinancialIndicators?$apply=filter(financialDataSet eq 'Pledges_Contributions')/groupby((periodCovered))&$orderby=periodCovered asc",
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/allocations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export class AllocationsController {
let filterString = filterFinancialIndicators(
{...this.req.query, geographies: countryCode},
AllocationRadialFieldsMapping.urlParamsLocation,
['geography/name', 'geography/code'],
'geography/code',
'activityArea/name',
);

Expand Down
33 changes: 21 additions & 12 deletions src/controllers/grants.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,31 @@ export class GrantsController {
@param.path.string('pageSize') pageSize: string,
) {
const mapper = mapTransform(GrantsListMapping.map);
const params = querystring.stringify(
{
...getPage(filtering.page, parseInt(page, 10), parseInt(pageSize, 10)),
[filtering.page_size]: pageSize,
},
'&',
filtering.param_assign_operator,
{
encodeURIComponent: (str: string) => str,
},
);
const params =
pageSize === 'all'
? ''
: querystring.stringify(
{
...getPage(
filtering.page,
parseInt(page, 10),
parseInt(pageSize, 10),
),
[filtering.page_size]: pageSize,
},
'&',
filtering.param_assign_operator,
{
encodeURIComponent: (str: string) => str,
},
);
const filterString = filterGrants(
this.req.query,
GrantsListMapping.urlParams,
);
const url = `${urls.GRANTS}${filterString}&${params}`;
const url = `${urls.GRANTS}${filterString}${
params.length > 0 ? `&${params}` : params
}`;

return axios
.get(url)
Expand Down
Loading

0 comments on commit a7f557a

Please sign in to comment.