From a67b6ffcb0d2a09bdecf59a9116b0a5dbe2fc94d Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 7 Nov 2023 12:47:25 -0300 Subject: [PATCH] fix(viirs): add validation in fetchVIIRSAlertsSum To avoid confidence__cat = 'h' to be added on the query, since we always fetch by all alerts --- services/analysis-cached.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 0eafe2f79d..cadfcb7e27 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -2288,20 +2288,37 @@ export const fetchVIIRSAlertsSumOTF = (params) => { export const fetchVIIRSAlertsSum = (params) => { const { startDate, endDate, dataset } = params || {}; + /* + * Removing confidence parameter from VIIRS layer options + * for Fire Alerts widget, we always fetch all alerts + * and calculate the values directly on the selector.js + */ + const paramKeys = Object.keys(params).filter( + (param) => param !== 'confidence' + ); + const paramsWithoutConfidenceAlert = {}; + + paramKeys.forEach((parameter) => { + paramsWithoutConfidenceAlert[parameter] = params[parameter]; + }); + const url = encodeURI( `${getRequestUrl({ - ...params, + ...paramsWithoutConfidenceAlert, dataset, datasetType: 'daily', })}${SQL_QUERIES.firesDailySum}` .replace( /{select_location}/g, - getLocationSelect({ ...params, cast: false }) + getLocationSelect({ ...paramsWithoutConfidenceAlert, cast: false }) ) - .replace(/{location}/g, getLocationSelect(params)) + .replace(/{location}/g, getLocationSelect(paramsWithoutConfidenceAlert)) .replace('{startDate}', startDate) .replace('{endDate}', endDate) - .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'viirs' })) + .replace( + '{WHERE}', + getWHEREQuery({ ...paramsWithoutConfidenceAlert, dataset: 'viirs' }) + ) ); return dataRequest.get(url).then((response) => ({