Skip to content

Commit

Permalink
Merge pull request #4739 from wri/feat/flag-986
Browse files Browse the repository at this point in the history
FLAG-986 | Adjust warning sentence to DRC TCL / emissions widgets
  • Loading branch information
wri7tno authored Jan 26, 2024
2 parents 52291bb + 97a1c73 commit d188e6d
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const getLocationName = (state) => state.locationLabel;
const getColors = (state) => state.colors;
const getSentences = (state) => state.sentences;
const getTitle = (state) => state.title;
const getAlerts = (state) => state.alerts || [];
const getAdm0 = (state) => state.adm0;

export const getPermCats = createSelector([], () =>
tscLossCategories.filter((x) => x.permanent).map((el) => el.value.toString())
Expand Down Expand Up @@ -241,9 +243,41 @@ export const parseTitle = createSelector(
}
);

export const parseAlerts = createSelector(
[getAlerts, getLocationName, getAdm0],
(alerts, locationLabel, adm0) => {
const countriesWithNewWarningText = [
'CMR',
'CIV',
'COD',
'GNQ',
'GAB',
'GHA',
'GIN',
'GNB',
'LBR',
'MDG',
'COG',
'SLE',
];

if (countriesWithNewWarningText.includes(adm0)) {
return [
{
text: `The methods behind the annual tree cover loss data underlying emissions estimates have changed over time, resulting in an underreporting of tree cover loss in ${locationLabel} prior to 2015. We advise against comparing the data before/after 2015 in ${locationLabel}. [Read more here](https://www.globalforestwatch.org/blog/data-and-research/tree-cover-loss-satellite-data-trend-analysis/).`,
visible: ['global', 'country', 'geostore', 'aoi', 'wdpa', 'use'],
},
];
}

return alerts;
}
);

export default createStructuredSelector({
data: parseData,
config: parseConfig,
sentence: parseSentence,
title: parseTitle,
alerts: parseAlerts,
});
34 changes: 34 additions & 0 deletions components/widgets/climate/emissions-deforestation/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const getColors = (state) => state.colors;
const getIndicator = (state) => state.indicator;
const getLocationName = (state) => state.locationLabel;
const getSentences = (state) => state.sentences;
const getAlerts = (state) => state.alerts || [];
const getAdm0 = (state) => state.adm0;

export const parseData = createSelector(
[getData, getSettings],
Expand Down Expand Up @@ -133,8 +135,40 @@ export const parseSentence = createSelector(
}
);

export const parseAlerts = createSelector(
[getAlerts, getLocationName, getAdm0],
(alerts, locationLabel, adm0) => {
const countriesWithNewWarningText = [
'CMR',
'CIV',
'COD',
'GNQ',
'GAB',
'GHA',
'GIN',
'GNB',
'LBR',
'MDG',
'COG',
'SLE',
];

if (countriesWithNewWarningText.includes(adm0)) {
return [
{
text: `The methods behind the annual tree cover loss data underlying emissions estimates have changed over time, resulting in an underreporting of tree cover loss in ${locationLabel} prior to 2015. We advise against comparing the data before/after 2015 in ${locationLabel}. [Read more here](https://www.globalforestwatch.org/blog/data-and-research/tree-cover-loss-satellite-data-trend-analysis/).`,
visible: ['global', 'country', 'geostore', 'aoi', 'wdpa', 'use'],
},
];
}

return alerts;
}
);

export default createStructuredSelector({
data: parseData,
config: parseConfig,
sentence: parseSentence,
alerts: parseAlerts,
});
34 changes: 34 additions & 0 deletions components/widgets/fires/tree-loss-fires-annual/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const getIndicator = (state) => state.indicator;
const getColors = (state) => state.colors;
const getSentence = (state) => state && state.sentence;
const getChartDecorationConfig = (state) => state.chartDecorationConfig;
const getAlerts = (state) => state.alerts || [];
const getAdm0 = (state) => state.adm0;

const sumByYear = (data) => {
const groupedByYear = groupBy(data, 'year');
Expand Down Expand Up @@ -211,9 +213,41 @@ export const parseTitle = createSelector(
}
);

export const parseAlerts = createSelector(
[getAlerts, getLocationLabel, getAdm0],
(alerts, locationLabel, adm0) => {
const countriesWithNewWarningText = [
'CMR',
'CIV',
'COD',
'GNQ',
'GAB',
'GHA',
'GIN',
'GNB',
'LBR',
'MDG',
'COG',
'SLE',
];

if (countriesWithNewWarningText.includes(adm0)) {
return [
{
text: `The methods behind this data have changed over time, resulting in an underreporting of tree cover loss in ${locationLabel} prior to 2015. We advise against comparing the data before/after 2015 in ${locationLabel}. [Read more here](https://www.globalforestwatch.org/blog/data-and-research/tree-cover-loss-satellite-data-trend-analysis/).`,
visible: ['global', 'country', 'geostore', 'aoi', 'wdpa', 'use'],
},
];
}

return alerts;
}
);

export default createStructuredSelector({
data: zeroFillData,
config: parseConfig,
sentence: parseSentence,
title: parseTitle,
alerts: parseAlerts,
});
31 changes: 29 additions & 2 deletions components/widgets/forest-change/tree-loss-drivers/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const getSentences = (state) => state.sentences;
const getAlerts = (state) => state.alerts;
const getTitle = (state) => state.title;
const getAdm0 = (state) => state.adm0;
const getLocationLabel = (state) => state.locationLabel;

export const getPermCats = createSelector([], () =>
tscLossCategories.filter((x) => x.permanent).map((el) => el.value.toString())
Expand Down Expand Up @@ -259,8 +260,34 @@ export const parseTitle = createSelector(
);

export const parseAlerts = createSelector(
[getAlerts, getAdm0],
(alerts, adm0) => (adm0 === 'IDN' ? alerts.indonesia : alerts.default)
[getAlerts, getAdm0, getLocationLabel],
(alerts, adm0, locationLabel) => {
const countriesWithNewWarningText = [
'CMR',
'CIV',
'COD',
'GNQ',
'GAB',
'GHA',
'GIN',
'GNB',
'LBR',
'MDG',
'COG',
'SLE',
];

if (countriesWithNewWarningText.includes(adm0)) {
return [
{
text: `The methods behind this data have changed over time, resulting in an underreporting of tree cover loss in ${locationLabel} prior to 2015. We advise against comparing the data before/after 2015 in ${locationLabel}. [Read more here](https://www.globalforestwatch.org/blog/data-and-research/tree-cover-loss-satellite-data-trend-analysis/).`,
visible: ['global', 'country', 'geostore', 'aoi', 'wdpa', 'use'],
},
];
}

return adm0 === 'IDN' ? alerts.indonesia : alerts.default;
}
);

export default createStructuredSelector({
Expand Down
34 changes: 34 additions & 0 deletions components/widgets/forest-change/tree-loss-primary/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const getPrimaryLoss = (state) => state.data && state.data.primaryLoss;
const getAdminLoss = (state) => state.data && state.data.adminLoss;
const getSettings = (state) => state.settings;
const getLocationLabel = (state) => state.locationLabel;
const getAlerts = (state) => state.alerts || [];
const getAdm0 = (state) => state.adm0;
const getIndicator = (state) => state.indicator;
const getColors = (state) => state.colors;
const getSentence = (state) => state && state.sentence;
Expand Down Expand Up @@ -162,6 +164,37 @@ export const parseTitle = createSelector(
}
);

export const parseAlerts = createSelector(
[getAlerts, getLocationLabel, getAdm0],
(alerts, locationLabel, adm0) => {
const countriesWithNewWarningText = [
'CMR',
'CIV',
'COD',
'GNQ',
'GAB',
'GHA',
'GIN',
'GNB',
'LBR',
'MDG',
'COG',
'SLE',
];

if (countriesWithNewWarningText.includes(adm0)) {
return [
{
text: `The methods behind this data have changed over time, resulting in an underreporting of tree cover loss in ${locationLabel} prior to 2015. We advise against comparing the data before/after 2015 in ${locationLabel}. [Read more here](https://www.globalforestwatch.org/blog/data-and-research/tree-cover-loss-satellite-data-trend-analysis/).`,
visible: ['global', 'country', 'geostore', 'aoi', 'wdpa', 'use'],
},
];
}

return alerts;
}
);

const parseSentence = createSelector(
[
parseData,
Expand Down Expand Up @@ -249,4 +282,5 @@ export default createStructuredSelector({
config: parseConfig,
sentence: parseSentence,
title: parseTitle,
alerts: parseAlerts,
});
34 changes: 34 additions & 0 deletions components/widgets/forest-change/tree-loss/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const getLocationLabel = (state) => state.locationLabel;
const getIndicator = (state) => state.indicator;
const getColors = (state) => state.colors;
const getSentence = (state) => state && state.sentence;
const getAlerts = (state) => state.alerts || [];
const getAdm0 = (state) => state.adm0;

const parseData = createSelector(
[getLoss, getExtent, getSettings],
Expand Down Expand Up @@ -161,8 +163,40 @@ const parseSentence = createSelector(
}
);

export const parseAlerts = createSelector(
[getAlerts, getLocationLabel, getAdm0],
(alerts, locationLabel, adm0) => {
const countriesWithNewWarningText = [
'CMR',
'CIV',
'COD',
'GNQ',
'GAB',
'GHA',
'GIN',
'GNB',
'LBR',
'MDG',
'COG',
'SLE',
];

if (countriesWithNewWarningText.includes(adm0)) {
return [
{
text: `The methods behind this data have changed over time, resulting in an underreporting of tree cover loss in ${locationLabel} prior to 2015. We advise against comparing the data before/after 2015 in ${locationLabel}. [Read more here](https://www.globalforestwatch.org/blog/data-and-research/tree-cover-loss-satellite-data-trend-analysis/).`,
visible: ['global', 'country', 'geostore', 'aoi', 'wdpa', 'use'],
},
];
}

return alerts;
}
);

export default createStructuredSelector({
data: zeroFillData,
config: parseConfig,
sentence: parseSentence,
alerts: parseAlerts,
});

0 comments on commit d188e6d

Please sign in to comment.