Skip to content

Commit

Permalink
Merge pull request #4907 from wri/fix/get-loss-grouped
Browse files Browse the repository at this point in the history
fix(tree-gain): widgets are not displaying data
  • Loading branch information
willian-viana authored Jan 3, 2025
2 parents 96ada85 + b401ecd commit aa4e469
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/cypress/support
/cypress/plugins
/newrelic
/services/country-links.json
11 changes: 8 additions & 3 deletions components/widgets/forest-change/tree-cover-gain/index.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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'
Expand All @@ -126,10 +130,11 @@ export default {
};
});
}

return mappedData;
})
);
},
getDataURL: (params) => [getGain({ ...params, download: true })],
getDataURL: (params) => [getGainGrouped({ ...params, download: true })],
getWidgetProps,
};
2 changes: 1 addition & 1 deletion services/analysis-cached.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const typeByGrouped = {
},
adm1: {
default: 'adm1',
grouped: 'adm1',
grouped: 'adm2',
},
adm2: {
default: 'adm2',
Expand Down

0 comments on commit aa4e469

Please sign in to comment.