Open NealHumphrey opened 7 years ago
Merging initial portions of this into dev per PR #416
Still to do:
Merged in some more changes in #436 . Changes requested from that code version:
PR changes requested by @nealhumphrey
And @jkwening 's list in the PR:
@NealHumphrey I crossed the to do bullet that you asked clarification about; it seems I misunderstood the following action item:
zone_type and zone_specific (i.e. "ward" and "Ward 1" or "neighborhood_cluster" and "Cluster 32"). zone_type should match the relevant standard column name and zone_specific should match the value for that column that is used in other tables
I think we discussed this a couple weeks ago. I thought this implied that in addition to each unique zone_specific value for a zone_type populated in the zone column of zone_facts table you wanted the zone_type included and aggregate values populate. That is, zone column should include "ward", "census_tract", and "neighborhood_cluster" values in addition to their unique zone_specific values.
Ah, ok - yep, all I meant was that we do it as you've already done, with one column that designates whether it's Ward or Cluster or Tract etc.
@jkwening just a quick note - I crossed off the building permits bullet point b/c I made a separate issue for that one. I think the only things left on this for now are the unit tests bullet points
Instead of using our API endpoints to recalculate derivative fields adhoc, and instead of performing client-side reconfiguration of data into display fields, we want a master table to do these calculations every time new data is loaded and make it easier to join all these fields to the project table. We've previously referred to this as the 'NeighborhoodFacts' table.
This ticket should a) create the table and b) make the data in the table part of the filter_data endpoint (which has a record for each project/subsidy combo). This will make all of this data available to the combined filter/layer view that is being used in V2.
[x] Add a function that runs after all data loading is completed that drops the existing records from the zonefacts table and recalculates all the fields. Each row of the table should be one "zone" with the relevant calculated fields. Initial columns should be those that exist in our existing layers data set, with rows filled in for each zone for each of "ward", "neighborhood_cluster" and "census_tract".
[x] Left Join the project table to this table within the filter_data API endpoint. Do a left join 3 times, once each for ward, neighborhood_cluster and census_tract. For each join, the zones should be renamed
zonetype_columnname
. This means each row of the project data will have the denormalized data associated with all relevant zone types.