wri / gfw

Global Forest Watch: An online, global, near-real time forest monitoring tool
https://www.globalforestwatch.org
MIT License
273 stars 93 forks source link

FLAG-1114: create datamart api route #4810

Closed wri7tno closed 4 months ago

wri7tno commented 4 months ago

Overview

Create a new api route that serves as a proxy to hide all SQL details from client side, this PoC will serve as the first step to implement a data mart on the API side by the engineering team.

The new api route only works for the net change widget since it is a simple one that doesn't have dynamic filters.

Original client request:

https://gfw-staging-pr-4810.herokuapp.com/api/data/dataset/umd_adm2_net_tree_cover_change_from_height/v202209/query/?sql=SELECT iso, adm1, adm2, iso, adm1_name, adm2_name, stable, loss, gain, disturb, net, change, gfw_area__ha FROM data WHERE iso = 'MEX' AND adm1 = '9' AND adm2 = '3' 

New client request:

https://gfw-staging-pr-4810.herokuapp.com/api/datamart/net-change/?type=global&version=v202209&fields=iso,stable,loss,gain,disturb,net,change,gfw_area__ha&adm0=MEX&adm1=9&adm2=3

Demo

Screenshot 2024-06-24 at 10 19 32 a m

Notes

If applicable: ancilary topics, caveats, alternative strategies that didn't work out, etc.

Testing