Skip to content

Commit

Permalink
feat: cycles filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Jun 20, 2024
1 parent c7a570c commit ae89a98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/utils/filtering/eligibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const MAPPING = {
geography: ['geography/name', 'geography/code'],
component: 'activityArea/name',
year: 'eligibilityYear',
cycle: 'fundingStream',
};

export function filterEligibility(
Expand Down Expand Up @@ -53,6 +54,16 @@ export function filterEligibility(
}(${years.join(filtering.multi_param_separator)})`;
}

const cycles = _.filter(
_.get(params, 'cycles', '').split(','),
(o: string) => o.length > 0,
).map((cycle: string) => `'${cycle}'`);
if (cycles.length > 0) {
str += `${str.length > 0 ? ' AND ' : ''}${MAPPING.cycle}${
filtering.in
}(${cycles.join(filtering.multi_param_separator)})`;
}

// const search = _.get(params, 'q', '');
// if (search.length > 0) {
// str += `${str.length > 0 ? ' AND ' : ''}${MAPPING.search.replace(
Expand Down
8 changes: 6 additions & 2 deletions src/utils/filtering/financialIndicators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const MAPPING = {
principalRecipientType:
'implementationPeriod/grant/principalRecipient/type/parent/name',
period: 'periodCovered',
cycle: 'periodCovered',
year: 'implementationPeriod/periodFrom',
yearTo: 'implementationPeriod/periodTo',
grantIP: 'implementationPeriod/code',
Expand Down Expand Up @@ -108,9 +109,12 @@ export function filterFinancialIndicators(
}

const periods = _.filter(
_.get(params, 'periods', '').split(','),
[
..._.get(params, 'periods', '').split(','),
..._.get(params, 'cycles', '').split(','),
],
(o: string) => o.length > 0,
).map((period: string) => `'${period.replace(/ /g, '')}'`);
).map((period: string) => `'${period.replace(/ /g, '').replace(' - ', '')}'`);
if (periods.length > 0) {
str += `${str.length > 0 ? ' AND ' : ''}${MAPPING.period}${
filtering.in
Expand Down

0 comments on commit ae89a98

Please sign in to comment.