Skip to content

Commit

Permalink
Schema for home, case, billing period, and related data (no homeowner…
Browse files Browse the repository at this point in the history
…, coach yet) (#251)

* Modify schema.prisma

Co-authored-by: AdamFinkle <[email protected]>

* Created home and case entries

Co-authored-by: AdamFinkle <[email protected]>

* Add file table

Co-authored-by: AdamFinkle <[email protected]>

* Created all tables related to Case

Co-authored-by: AdamFinkle <[email protected]>

* Add summary output and relationships

Co-authored-by: AdamFinkle <[email protected]>

* Implement user-case many to many and change id to int

Co-authored-by: AdamFinkle <[email protected]>

* Added contacts.

* Required caseId and userId combination to be unique.

* Reimplement schema.prisma based on ERD

Co-authored-by: AdamFinkle <[email protected]>

* Remigrate scripts to have two clean scripts

* Add comment to schema.prisma

* Add test files

* Added experimental XML parsing.

* WIP saving progress

Saving work

* Rename directory

* Rename rules-engine to python

* Co-authored-by: AdamFinkle <[email protected]>
Co-authored-by: Deb Debnath <[email protected]>
Co-authored-by: stemgene <[email protected]>

* Changed prisma to match newly-modified ERD.

* Co-authored-by: AdamFinkle <[email protected]>
Co-authored-by: Deb Debnath <[email protected]>
Co-authored-by: stemgene <[email protected]>

* Restore package.json, package-lock.json from HEAD~v2 to fix prisma issue

* Modify schema.prisma to match ERD

Co-authored-by: AdamFinkle <[email protected]>

* Formatting

* Formatting

* Fix incorrect change to var name

* Restore missing file

* Reconcile with main

* Add return key

* Remove return key

---------

Co-authored-by: AdamFinkle <[email protected]>
Co-authored-by: Vlad Korolev <[email protected]>
Co-authored-by: AdamFinkle <[email protected]>
  • Loading branch information
4 people authored Feb 7, 2025
1 parent 053aad1 commit 24c828c
Show file tree
Hide file tree
Showing 11 changed files with 773 additions and 239 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
.DS_Store

.env

# Easy way to create temporary files/folders that won't accidentally be added to git
Expand All @@ -9,4 +8,4 @@ node_modules
#local temporary folders
heat-app
venv
heat-tmp
heat-tmp
53 changes: 34 additions & 19 deletions design_temp/validate_counties.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
CENSUS_DOCS_BASE_URL = "https://www2.census.gov/geo/docs/reference"
CENSUS_STATE_PATH = "/state.txt"
CENSUS_COUNTY_PATH = "/codes2020/national_county2020.txt"
CENSUS_DELIMETER = '|'
NEW_LINE = '\n'
NEW_HEADERS="state_id,state_name,state_abbr,county_fp,county_ns,county_name,county_design_temp"
CENSUS_DELIMETER = "|"
NEW_LINE = "\n"
NEW_HEADERS = (
"state_id,state_name,state_abbr,county_fp,county_ns,county_name,county_design_temp"
)


class State(BaseModel):
state_id: str
state_abbr: str
state_name: str


class County(BaseModel):
state_id: str
state_abbr: str
Expand All @@ -25,71 +29,82 @@ class County(BaseModel):
county_ns: str
county_name: str


class DTBC(BaseModel):
state: str
county: str
temp: int


_counties = {}
_states={}
_dtbc={}
_states = {}
_dtbc = {}


def load_design_temp_data():

with open(DESIGN_TEMP_DIR / "design_temp_by_county.csv") as f:
reader = csv.DictReader(f)
for row in reader:
item = DTBC(
state=row["state"], county=row["county"],temp=row["design_temp"]
state=row["state"], county=row["county"], temp=row["design_temp"]
)
if row["state"] in _dtbc:
_dtbc[row["state"]].append(item)
_dtbc[row["state"]].append(item)
else:
_dtbc[row["state"]] = [item]


def fetch_census_counties():
census_url = CENSUS_DOCS_BASE_URL + CENSUS_COUNTY_PATH

response = requests.get(census_url)
reader = csv.DictReader(f=io.StringIO(response.text),delimiter=CENSUS_DELIMETER)
reader = csv.DictReader(f=io.StringIO(response.text), delimiter=CENSUS_DELIMETER)

for row in reader:
sid = row["STATEFP"]
sn = _states[sid].state_name
item = County(
state_id=sid, state_abbr=_states[sid].state_abbr, state_name=sn,county_fp=row["COUNTYFP"], county_ns=row["COUNTYNS"],county_name=row["COUNTYNAME"]
state_id=sid,
state_abbr=_states[sid].state_abbr,
state_name=sn,
county_fp=row["COUNTYFP"],
county_ns=row["COUNTYNS"],
county_name=row["COUNTYNAME"],
)
_counties[sn].append(item)



def fetch_census_states():
states_url = CENSUS_DOCS_BASE_URL + CENSUS_STATE_PATH

response = requests.get(states_url)
reader = csv.DictReader(f=io.StringIO(response.text),delimiter=CENSUS_DELIMETER)
reader = csv.DictReader(f=io.StringIO(response.text), delimiter=CENSUS_DELIMETER)

for row in reader:
_counties[row["STATE_NAME"]] = []
item = State(
state_id=row["STATE"], state_abbr=row["STUSAB"], state_name=row["STATE_NAME"]
state_id=row["STATE"],
state_abbr=row["STUSAB"],
state_name=row["STATE_NAME"],
)
_states[row["STATE"]] = item



if __name__ == "__main__":

fetch_census_states()
fetch_census_counties()

load_design_temp_data()

with open(DESIGN_TEMP_DIR / "merged_structure_temps.csv", "w", newline=NEW_LINE) as oFile:
with open(
DESIGN_TEMP_DIR / "merged_structure_temps.csv", "w", newline=NEW_LINE
) as oFile:
oFile.write(NEW_HEADERS)
for s, cbs in _counties.items():
d_row = _dtbc.get(s)
if d_row:
for d in d_row:
for c in cbs:
if d.county in c.county_name:
ostr=f"\n{c.state_id},{s},{c.state_abbr},{c.county_fp},{c.county_ns},{d.county},{d.temp}"
oFile.write(ostr)
ostr = f"\n{c.state_id},{s},{c.state_abbr},{c.county_fp},{c.county_ns},{d.county},{d.temp}"
oFile.write(ostr)
7 changes: 2 additions & 5 deletions heat-stack/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions heat-stack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@epic-web/totp": "^1.1.2",
"@nasa-gcn/remix-seo": "^2.0.1",
"@paralleldrive/cuid2": "^2.2.2",
"@prisma/client": "^5.17.0",
"@prisma/client": "^5.19.1",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-label": "^2.1.0",
Expand Down Expand Up @@ -87,10 +87,9 @@
"intl-parse-accept-language": "^1.0.0",
"isbot": "^5.1.13",
"litefs-js": "^1.1.2",
"lucide-react": "^0.428.0",
"lru-cache": "^11.0.0",
"lucide-react": "^0.428.0",
"morgan": "^1.10.0",
"prisma": "^5.17.0",
"pyodide": "0.24.1",
"qrcode": "^1.5.3",
"react": "^18.3.1",
Expand Down Expand Up @@ -152,6 +151,7 @@
"prettier": "^3.3.3",
"prettier-plugin-sql": "^0.18.1",
"prettier-plugin-tailwindcss": "^0.6.5",
"prisma": "^5.19.1",
"remix-flat-routes": "^0.6.5",
"tsx": "^4.16.2",
"typescript": "^5.5.3",
Expand Down
Loading

0 comments on commit 24c828c

Please sign in to comment.