Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema for home, case, billing period, and related data (no homeowner, coach yet) #251

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fb43e4f
Modify schema.prisma
ethanstrominger Sep 10, 2024
149f1d4
Created home and case entries
ethanstrominger Sep 19, 2024
45ff6fb
Add file table
ethanstrominger Sep 20, 2024
4a8a40c
Created all tables related to Case
ethanstrominger Sep 23, 2024
9ad5606
Add summary output and relationships
ethanstrominger Sep 24, 2024
9fe9cfa
Implement user-case many to many and change id to int
ethanstrominger Sep 26, 2024
4825e02
Added contacts.
ethanstrominger Sep 30, 2024
d081bc9
Required caseId and userId combination to be unique.
ethanstrominger Sep 30, 2024
cd8e798
Reimplement schema.prisma based on ERD
ethanstrominger Oct 4, 2024
01f30a1
Remigrate scripts to have two clean scripts
ethanstrominger Oct 4, 2024
95d9b0a
Add comment to schema.prisma
ethanstrominger Oct 4, 2024
33c8670
Add test files
vladistan Sep 8, 2024
1083acd
Added experimental XML parsing.
AdamFinkle Aug 21, 2024
f5bffa2
WIP saving progress
vladistan Sep 4, 2024
0e7cfc5
Rename directory
ethanstrominger Oct 23, 2024
afe0653
Rename rules-engine to python
ethanstrominger Oct 23, 2024
e3d822a
Co-authored-by: AdamFinkle <AdamFinkle@users.noreply.github.com>
ethanstrominger Oct 25, 2024
549024e
Merge branch 'schema-prisma-124-v2' of https://github.com/ethanstromi…
AdamFinkle Oct 25, 2024
4ccc659
Changed prisma to match newly-modified ERD.
AdamFinkle Oct 25, 2024
c15842c
Co-authored-by: AdamFinkle <AdamFinkle@users.noreply.github.com>
ethanstrominger Oct 26, 2024
5c7d610
Restore package.json, package-lock.json from HEAD~v2 to fix prisma issue
ethanstrominger Oct 26, 2024
ca47512
Merge branch 'main' of github.com:codeforboston/home-energy-analysis-…
ethanstrominger Nov 11, 2024
934f406
Modify schema.prisma to match ERD
ethanstrominger Nov 11, 2024
7a2a149
Merge branch 'main' of github.com:codeforboston/home-energy-analysis-…
ethanstrominger Dec 9, 2024
d9e187a
Formatting
ethanstrominger Dec 9, 2024
d536a45
Formatting
ethanstrominger Dec 9, 2024
905e8b6
Fix incorrect change to var name
ethanstrominger Dec 10, 2024
5a889d3
Merge branch 'main' of github.com:codeforboston/home-energy-analysis-…
ethanstrominger Dec 10, 2024
2a30578
Merge branch 'main' into schema-prisma-124-v2
ethanstrominger Dec 10, 2024
6284ee5
Restore missing file
ethanstrominger Dec 10, 2024
486c0e0
Reconcile with main
ethanstrominger Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
66 changes: 41 additions & 25 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 @@ -50,7 +50,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 @@ -86,10 +86,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 @@ -151,6 +150,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
Loading