Skip to content

Commit

Permalink
Merge pull request #4684 from wri/revert-4681-FLAG-900-undefined-year…
Browse files Browse the repository at this point in the history
…-causing-an-error-in-the-tcl-due-to-fires-widget-in-protected-and-some-custom-area-dashboards

Revert "FLAG-900: Undefined year causing an error in the TCL due to Fires widget in protected and some custom area dashboards"
  • Loading branch information
SARodrigues authored Sep 5, 2023
2 parents 2fb1526 + a2e618d commit 0a2ab50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 10 additions & 7 deletions components/widgets/fires/tree-loss-fires-annual/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import {

import getWidgetProps from './selectors';

const MAX_YEAR = 2022;
const MIN_YEAR = 2001;

const getGlobalLocation = (params) => ({
adm0: params.type === 'global' ? null : params.adm0,
adm1: params.type === 'global' ? null : params.adm1,
Expand Down Expand Up @@ -635,11 +638,9 @@ export default {
settings: {
threshold: 30,
ifl: 2000,
startYear: 2001,
endYear: 2022,
},
getData: (params = {}) => {
const { adm0, adm1, adm2, type, startYear, endYear } = params || {};
const { adm0, adm1, adm2, type } = params || {};

const globalLocation = {
adm0: type === 'global' ? null : adm0,
Expand All @@ -665,17 +666,19 @@ export default {
};
}

const { range: yearsRange } = getYearsRangeFromMinMax(startYear, endYear);

const { startYear, endYear, range } = getYearsRangeFromMinMax(
MIN_YEAR,
MAX_YEAR
);
return {
...data,
settings: {
startYear,
endYear,
yearsRange,
yearsRange: range,
},
options: {
years: yearsRange,
years: range,
},
};
});
Expand Down
4 changes: 1 addition & 3 deletions services/analysis-cached.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const SQL_QUERIES = {
lossFires:
'SELECT {select_location}, umd_tree_cover_loss__year, SUM(umd_tree_cover_loss__ha) AS umd_tree_cover_loss__ha, SUM(umd_tree_cover_loss_from_fires__ha) AS "umd_tree_cover_loss_from_fires__ha" FROM data {WHERE} GROUP BY umd_tree_cover_loss__year, {location} ORDER BY umd_tree_cover_loss__year, {location}',
lossFiresOTF:
'SELECT umd_tree_cover_loss__year, sum(umd_tree_cover_loss__ha), sum(umd_tree_cover_loss_from_fires__ha) FROM data WHERE umd_tree_cover_loss__year >= {startYear} AND umd_tree_cover_loss__year <= {endYear} AND umd_tree_cover_density_2000__threshold >= {threshold} GROUP BY umd_tree_cover_loss__year',
'SELECT umd_tree_cover_loss__year, sum(umd_tree_cover_loss__ha), sum(umd_tree_cover_loss_from_fires__ha) FROM data WHERE umd_tree_cover_loss__year >= {startYear} AND umd_tree_cover_loss__year <= {endYear} AND umd_tree_cover_density_2000__threshold >= 30 GROUP BY umd_tree_cover_loss__year',
emissions:
'SELECT {select_location}, umd_tree_cover_loss__year, SUM("gfw_gross_emissions_co2e_all_gases__Mg") AS "gfw_gross_emissions_co2e_all_gases__Mg", SUM("gfw_full_extent_gross_emissions_non_CO2__Mg_CO2e") AS "gfw_gross_emissions_co2e_non_co2__Mg", SUM("gfw_full_extent_gross_emissions_CO2_only__Mg_CO2") AS "gfw_gross_emissions_co2e_co2_only__Mg" FROM data {WHERE} GROUP BY umd_tree_cover_loss__year, {location} ORDER BY umd_tree_cover_loss__year, {location}',
emissionsLossOTF:
Expand Down Expand Up @@ -817,7 +817,6 @@ export const getLossFiresOTF = (params) => {
geostore,
startYear,
endYear,
threshold,
} = params || {};

const geostoreId = geostore.id || adm0;
Expand All @@ -828,7 +827,6 @@ export const getLossFiresOTF = (params) => {
`${urlBase + sql}&geostore_id=${geostoreId}`
.replace('{startYear}', startYear)
.replace('{endYear}', endYear)
.replace('{threshold}', threshold)
);

if (download) {
Expand Down

0 comments on commit 0a2ab50

Please sign in to comment.