NYCPlanning / deprecated-labs-zap-api

Deprecated version of the ZAP API, see https://github.com/NYCPlanning/labs-zap-api
Other
5 stars 3 forks source link

radiusDistanceQuery should not run multiple times for every map click #111

Closed trbmcginnis closed 5 years ago

trbmcginnis commented 5 years ago

Right now the radiusDistanceQuery will run several times each time a user clicks on the map to make a point. The frontend is not making multiple requests to the backend, so this is something happening in the API.

This might be slowing down the frontend which is causing the lag in the project filter (time difference between when a user clicks and the actual filtering happens).

This is because the radiusDistanceQuery is run when the tiles query runs type === 'tiles' in build-project-sql

The filtering should only happen ONCE, but the tiles need to be reconfigured when a user zooms in and out / pans around the map. How can we filter the database once and before we build the tiles, so that this query doesn't have to rerun every time we build a new tile. --> this might be the reason that the old point's project points flash when creating a new point, but I don't think it explains why it takes so long for the project geometries to initially show up after clicking a point. ??

What's causing it to take a long time--the database query or the tile building? I'm assuming the tile building

trbmcginnis commented 5 years ago

Lag:

persisting_radius_filter.png

trbmcginnis commented 5 years ago

New tiles are generated every time the map pans or zooms, meaning the tile query is being run every time the user moves around the map. Because we need to build geometries when we run radiusDistanceQuery, this query will run every time with the tiles query, which is why we were seeing radiusDistanceQuery repeated so many times in the backend. Right now, tiles are being requested while map.flyTo() is in transit, meaning there are excessive requests to the backend.

What we found out: