From cd3532515de27c12a75591fd53560b9a8d473e2d Mon Sep 17 00:00:00 2001 From: Bryan Marchena Date: Tue, 2 Apr 2024 10:48:00 -0400 Subject: [PATCH] Change FEMA filter logic to be inclusive --- server/src/crm/crm.utilities.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/server/src/crm/crm.utilities.ts b/server/src/crm/crm.utilities.ts index 2360268be..b1eb98989 100644 --- a/server/src/crm/crm.utilities.ts +++ b/server/src/crm/crm.utilities.ts @@ -37,9 +37,20 @@ export function mapInLookup(arrayOfStrings, lookupHash) { } export function all(...statements): string { - return statements - .filter(Boolean) - .join(' and '); + const femaFloodZoneFilters = statements.filter(statement => { + if (statement.includes('femafloodzone')) return statement + }) + + if (femaFloodZoneFilters.length > 0) { + const femaFilterString = femaFloodZoneFilters.join(' or '); + const filterString = statements.filter(Boolean).join(' and '); + + const allStatements = filterString.concat(' and ', `((${femaFilterString}))`); + console.log('filterQuery', allStatements); + return allStatements; + } + + return statements.filter(Boolean).join(' and ') } export function any(...statements): string {