From 4387ac4ff070b30efa639b884e18f9686349cab0 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 7 Nov 2023 12:48:31 -0300 Subject: [PATCH] fix(viirs): validating the new option from the VIIRS layer to avoid errors on the query --- services/get-where-query.js | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/services/get-where-query.js b/services/get-where-query.js index b5de2ff1a7..617418e0db 100644 --- a/services/get-where-query.js +++ b/services/get-where-query.js @@ -37,46 +37,23 @@ export const getWHEREQuery = (params = {}) => { } /* - * Removing confidence_cat = 'false' from VIIRS request + * Removing confidence_cat = 'all' from VIIRS request * if the user selects 'all alerts' on the VIIRS layer, * we don't want to add a new parameter to the query */ - if (isVIIRS) { - if ( - typeof params?.confidence === 'boolean' && - params?.confidence === false - ) { - paramKeys = paramKeys.filter((item) => item !== 'confidence'); - } - if (params?.confidence === 'false' || params?.confidence === 'true') { - paramKeys = paramKeys.filter((item) => item !== 'confidence'); - } + if (isVIIRS && params?.confidence === 'all') { + paramKeys = paramKeys.filter((item) => item !== 'confidence'); } paramKeys.forEach((parameter, index) => { const isLastParameter = paramKeys.length - 1 === index; const hasFilterOption = ['forestType', 'landCategory'].includes(parameter); - let value = hasFilterOption ? 1 : params[parameter]; + const value = hasFilterOption ? 1 : params[parameter]; const filterOption = allFilterOptions.find( (pname) => pname.value === params[parameter] ); - /* - * when the user selects high confidence on VIIRS Layer - * the confidence option returns a string 'true' - * the right value should be 'h' - * Until we fix this return, we need to validate the parameter - */ - if (isVIIRS && parameter === 'confidence') { - if ( - typeof params?.confidence === 'boolean' && - params?.confidence === true - ) { - value = 'h'; - } - } - const tableKey = filterOption && (filterOption.tableKey || filterOption.tableKeys[dataset || 'annual']);