Skip to content

Commit

Permalink
fix(viirs): add validation in fetchVIIRSAlertsSum
Browse files Browse the repository at this point in the history
To avoid confidence__cat = 'h' to be added on the query, since we always fetch by all alerts
  • Loading branch information
willian-viana committed Nov 7, 2023
1 parent c92c5ec commit a67b6ff
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions services/analysis-cached.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down

0 comments on commit a67b6ff

Please sign in to comment.