Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLAG-900: Undefined year causing an error in the TCL due to Fires widget in protected and some custom area dashboards #4681

Conversation

SARodrigues
Copy link
Collaborator

@SARodrigues SARodrigues commented Sep 1, 2023

Overview

This PR fixes the issue where the fires widget breaks when it is set to do an OTF analysis, due to missing start and year years in the settings, causing the SQL query to be misconstructed.

Notes

It also includes a minor refactoring to the data processing in an attempt to prevent such mistakes by using the widgets' settings as the source of truth, and enables the "Years" setting that seems to have been missing for a while.

Testing

Test the links from the JIRA task (linked below) on this staging environment, verify that they now work.

Tracking

FLAG-900

@SARodrigues SARodrigues self-assigned this Sep 1, 2023
@willian-viana willian-viana temporarily deployed to gfw-staging-pr-4681 September 1, 2023 12:09 Inactive
@SARodrigues SARodrigues marked this pull request as ready for review September 1, 2023 13:18
@@ -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 >= 30 GROUP BY umd_tree_cover_loss__year',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, wonder why did we have a hardcoded value here 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely an oversight that evaded Code Review and QA. I've added my thoughts as to how it may happened to the JIRA task. I would guess that during the development of a new widget, the example SQL query we get from the data team was used directly in order to build the widget, and then we missed the fact we need to do interpolation as well.

We had a similar issue before, concerning the {startYear} and {endYear} addressed here.

@wri7tno
Copy link
Collaborator

wri7tno commented Sep 1, 2023

LGTM, tested 👍

Copy link
Collaborator

@willian-viana willian-viana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@SARodrigues SARodrigues merged commit 2fb1526 into develop Sep 5, 2023
4 checks passed
@SARodrigues SARodrigues deleted the FLAG-900-undefined-year-causing-an-error-in-the-tcl-due-to-fires-widget-in-protected-and-some-custom-area-dashboards branch September 5, 2023 10:04
@SARodrigues SARodrigues restored the FLAG-900-undefined-year-causing-an-error-in-the-tcl-due-to-fires-widget-in-protected-and-some-custom-area-dashboards branch September 5, 2023 10:11
@SARodrigues SARodrigues temporarily deployed to gfw-staging-br-flag-900-undefi September 5, 2023 10:49 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants