massenergize / api

Backend Code for Massenergize Portal. This provides the API to the backend database, and is shared by the various front-end portal projects.
MIT License
5 stars 8 forks source link

RealEstateUnit address not set on user creation #1007

Open BradHN1 opened 3 months ago

BradHN1 commented 3 months ago

Describe the bug RealEstateUnit has an address field, which is a foreign key link to a Location.
It also has a redundant "Location" json field which was the original version, perhaps this should have been eliminated.

The code was updated a couple years ago to use the address field to determine which households (RealEstateUnit) were in which zip code, so actions, households and carbon could be properly attributed.

Unfortunately users.create was not updating the address field so new households mostly do not have it.

Two parts to this ticket:

  1. make users.create create the household with the address field properly filled in
  2. backfill the existing RealEstate units to fill in the address from the location field. For this there was a task in misc.py called backfill_real_estate_units; moving this to a Task so it can be invoked from the admin portal like other tasks.
BradHN1 commented 3 months ago

Additionally, Community Location values were generally saved as ZIP_CODE_ONLY. The task backfill_data updates those locations with County, State information where appropriate