NYCPlanning / labs-factfinder-api

Search API for for labs-nyc-factfinder
Other
6 stars 3 forks source link

Data doesn't load when tracts or NTAs with 0 population are selected. #288

Open jpiacentinidcp opened 5 months ago

jpiacentinidcp commented 5 months ago

ADO ticket: https://dev.azure.com/NYCPlanning/ITD/_workitems/edit/5407

jpiacentinidcp commented 5 months ago

when you select 2 or more tracts or NTAs (works ok for blocks) with 0 population (+additional park tracts/NTAs, doesn't have to be 0 pop), data explorer doesn't load. If you selected 2 or more tracts or NTAs with 0 population + residential tract, then it loads. If you select 1 tract/NTA with 0 population, it loads. No idea what the issue is because there's nothing to distinguish park tracts in the database. seems to be an issue for non-park tracts with 0 population, as well.

jpiacentinidcp commented 5 months ago

ADO ticket: https://dev.azure.com/NYCPlanning/ITD/_workitems/edit/5407

TylerMatteo commented 5 months ago

@jpiacentinidcp Yeah this one is very odd but we can definitely investigate

For anyone looking to play around with reproducing in a non-local environment, I suggest using staging - it has the DB performance improvements so it will be much more performant.

This may already be covered in one scenarios described above but I noticed the data fails to load if you select one park tract with 0 pop and one with > 0 pop (screenshot from staging): image

But it does work if you select one 0 pop tract and one > 0 pop residential tract: image

In any case, this will take some digging. As we get into debugging this, it's probably best not to get too hung up on the park vs non-park thing as it could be a red herring. Not to say it's definitely not part of the issue, but I'm struggling to think of anywhere the code makes the distinction between park/non-park tracts and NTAs

TylerMatteo commented 5 months ago

Transferred to the PFF backend repo but the fix here could be in either the front end or back end, or a combination of the two.

TylerMatteo commented 5 months ago

@horatiorosa I'm adding @bmarchena to this as well since it sounds like you haven't had a chance to pick this up yet.

bmarchena commented 5 months ago

@TylerMatteo I've been able to trace the issue to this function we're using, "executeWithData".

Specifically, this function is failing when it tries to parse either our sum or sum_ratio formulas. These formulas are attempting to divide by 0 when a tract is selected without a population.

The problem is that we currently don't have a way of validating the values before the formula is parsed and executed. These values are simply strings of variable names until the parser uses a custom get function to get the appropriate values, and by that point the parser will execute the formula and error out.

TylerMatteo commented 4 months ago

@jpiacentinidcp @bmarchena Based on Bryan's findings, I'm recommending we backlog this because of the effort it would take to fix. I'll leave it open but set it to have no Iteration so it will still show up in the backlog.