From 4cc7b3cda861889f3481223871445315a49db8f6 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 20 Sep 2024 16:09:26 -0300 Subject: [PATCH 1/2] fix(tcl): add startYear and endYear to settings object Without it, the first params object won't have these properties and will break the chart --- components/widgets/forest-change/tree-loss/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/widgets/forest-change/tree-loss/index.js b/components/widgets/forest-change/tree-loss/index.js index 12a367c562..75561e7080 100644 --- a/components/widgets/forest-change/tree-loss/index.js +++ b/components/widgets/forest-change/tree-loss/index.js @@ -120,6 +120,8 @@ export default { threshold: 30, extentYear: 2000, ifl: 2000, + startYear: MIN_YEAR, + endYear: MAX_YEAR, }, getData: (params = {}) => { const { adm0, adm1, adm2, type } = params || {}; From 276def17e4e6a29a484199fbf736be43b0c890a3 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 20 Sep 2024 16:10:10 -0300 Subject: [PATCH 2/2] fix(tcl): add extentYear to the query Now when the user change extent year option, the query will be updated --- services/analysis-cached.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 69df52f485..39d76fc1f4 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -92,7 +92,7 @@ const SQL_QUERIES = { treeCoverDensity: 'SELECT {select_location}, wri_tropical_tree_cover__decile, SUM(wri_tropical_tree_cover_extent__ha) AS wri_tropical_tree_cover_extent__ha FROM data {WHERE} AND wri_tropical_tree_cover__decile >= 0 GROUP BY {location}, wri_tropical_tree_cover__decile ORDER BY {location}, wri_tropical_tree_cover__decile', treeLossOTF: - 'SELECT umd_tree_cover_loss__year, SUM(area__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&geostore_id={geostoreId}', + 'SELECT umd_tree_cover_loss__year, SUM(area__ha) FROM data WHERE umd_tree_cover_loss__year >= {startYear} AND umd_tree_cover_loss__year <= {endYear} AND umd_tree_cover_density_{extentYear}__threshold >= {threshold} GROUP BY umd_tree_cover_loss__year&geostore_id={geostoreId}', treeLossOTFExtent: 'SELECT SUM(area__ha) FROM data WHERE umd_tree_cover_density_2000__threshold >= {threshold}&geostore_id={geostoreId}', }; @@ -692,6 +692,7 @@ export const getTreeLossOTF = async (params) => { geostore, startYear, endYear, + extentYear, threshold, } = params || {}; @@ -707,6 +708,7 @@ export const getTreeLossOTF = async (params) => { .replace('{startYear}', startYear) .replace('{endYear}', endYear) .replace('{threshold}', threshold) + .replace('{extentYear}', extentYear) ); const urlExtent = encodeURI( `${urlForExtent + sqlExtent}`