Skip to content

Commit

Permalink
feat: funding requests component filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Jul 9, 2024
1 parent db64aa4 commit 526d2ae
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/config/mapping/fundingrequests/table-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
]
}
],
"urlParams": "?$filter=<filterString>&$expand=geography,implementationPeriods($expand=milestones,grant($expand=principalRecipient))"
"urlParams": "?$filter=<filterString>&$select=name,submissionDate,reviewApproach,window,reviewOutcome,reviewDate,differentiationCategory&$expand=geography($select=name),implementationPeriods($select=periodStartDate,periodEndDate;$expand=milestones($select=date),grant($select=code;$expand=principalRecipient($select=name)))"
}
33 changes: 23 additions & 10 deletions src/controllers/fundingrequests.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export class FundingRequestsController {

const groupedByGeo = _.groupBy(data, Table2FieldsMapping.groupby);

return {
let result: {
data: any;
signedCount?: any;
submittedCount?: any;
} = {
data: _.map(groupedByGeo, (items, key) => {
return {
components: key,
Expand Down Expand Up @@ -72,15 +76,24 @@ export class FundingRequestsController {
}),
};
}),
submittedCount: _.map(groupedByGeo, (items, key) => ({
name: key,
count: items.length,
})),
signedCount: _.map(groupedByGeo, (items, key) => ({
name: key,
count: _.filter(items, (item: any) => item.items.length > 0).length,
})),
};

if (this.req.query.withCounts) {
result = {
...result,
submittedCount: _.map(groupedByGeo, (items, key) => ({
name: key,
count: items.length,
})),
signedCount: _.map(groupedByGeo, (items, key) => ({
name: key,
count: _.filter(items, (item: any) => item.items.length > 0)
.length,
})),
};
}

return result;
})
.catch(handleDataApiError);
}
Expand All @@ -92,7 +105,7 @@ export class FundingRequestsController {
) {
return axios
.get(
`http://localhost:4200/funding-requests?geographies=${countryCode}&periods=${this.req.query.periods}`,
`http://localhost:4200/funding-requests?withCounts=1&geographies=${countryCode}&periods=${this.req.query.periods}`,
)
.then((resp: AxiosResponse) => resp.data)
.catch(handleDataApiError);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/filtering/fundingRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {getGeographyValues} from './geographies';

const MAPPING = {
geography: ['geography/name', 'geography/code'],
component: 'activityArea/name',
component: 'activityAreas/any(tag:tag/name in (<value>))',
period: 'periodFrom',
trpWindow: 'window',
portfolioCategory: 'differentiationCategory',
Expand Down

0 comments on commit 526d2ae

Please sign in to comment.