diff --git a/.eslintignore b/.eslintignore index 64e9acc0d4..b3d5823a58 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,3 +3,4 @@ /cypress/support /cypress/plugins /newrelic +/services/country-links.json diff --git a/components/widgets/forest-change/tree-cover-gain/index.js b/components/widgets/forest-change/tree-cover-gain/index.js index 46ee5b3c2b..2024e753d2 100644 --- a/components/widgets/forest-change/tree-cover-gain/index.js +++ b/components/widgets/forest-change/tree-cover-gain/index.js @@ -1,6 +1,6 @@ import { all, spread } from 'axios'; -import { getGain } from 'services/analysis-cached'; +import { getGainGrouped } from 'services/analysis-cached'; import { POLITICAL_BOUNDARIES_DATASET, @@ -104,17 +104,21 @@ export default { adm2: null, }; - return all([getGain({ ...rest, ...parentLocation })]).then( + return all([getGainGrouped({ ...rest, ...parentLocation })]).then( spread((gainResponse) => { let groupKey = 'iso'; + if (adm1) groupKey = 'adm1'; if (adm2) groupKey = 'adm2'; + const gainData = gainResponse.data.data; let mappedData = []; + if (gainData && gainData.length) { mappedData = gainData.map((item) => { const gain = item.gain || 0; const extent = item.extent || 0; + return { id: groupKey !== 'iso' @@ -126,10 +130,11 @@ export default { }; }); } + return mappedData; }) ); }, - getDataURL: (params) => [getGain({ ...params, download: true })], + getDataURL: (params) => [getGainGrouped({ ...params, download: true })], getWidgetProps, }; diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 81ea8a957a..8307e3c81f 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -110,7 +110,7 @@ const typeByGrouped = { }, adm1: { default: 'adm1', - grouped: 'adm1', + grouped: 'adm2', }, adm2: { default: 'adm2',