mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Added uprn to create_property
This commit is contained in:
parent
e82fa9c11f
commit
68458f1b91
2 changed files with 4 additions and 3 deletions
|
|
@ -11,7 +11,7 @@ from backend.app.db.models.portfolio import (
|
||||||
from sqlalchemy.orm.exc import NoResultFound
|
from sqlalchemy.orm.exc import NoResultFound
|
||||||
|
|
||||||
|
|
||||||
def create_property(session: Session, portfolio_id: int, address: str, postcode: str) -> (int, bool):
|
def create_property(session: Session, portfolio_id: int, address: str, postcode: str, uprn: str) -> (int, bool):
|
||||||
"""
|
"""
|
||||||
This function will create a record for the property in the database if it does not exist.
|
This function will create a record for the property in the database if it does not exist.
|
||||||
If it does exist, it will just update the updated_at field.
|
If it does exist, it will just update the updated_at field.
|
||||||
|
|
@ -25,7 +25,7 @@ def create_property(session: Session, portfolio_id: int, address: str, postcode:
|
||||||
try:
|
try:
|
||||||
# Attempt to fetch the existing property
|
# Attempt to fetch the existing property
|
||||||
existing_property = session.query(PropertyModel).filter_by(
|
existing_property = session.query(PropertyModel).filter_by(
|
||||||
address=address, postcode=postcode, portfolio_id=portfolio_id
|
uprn=uprn, portfolio_id=portfolio_id
|
||||||
).one()
|
).one()
|
||||||
|
|
||||||
# Update the 'updated_at' field
|
# Update the 'updated_at' field
|
||||||
|
|
@ -43,6 +43,7 @@ def create_property(session: Session, portfolio_id: int, address: str, postcode:
|
||||||
address=address,
|
address=address,
|
||||||
postcode=postcode,
|
postcode=postcode,
|
||||||
portfolio_id=portfolio_id,
|
portfolio_id=portfolio_id,
|
||||||
|
uprn=uprn,
|
||||||
creation_status=PropertyCreationStatus.LOADING,
|
creation_status=PropertyCreationStatus.LOADING,
|
||||||
status=PortfolioStatus.ASSESSMENT.value,
|
status=PortfolioStatus.ASSESSMENT.value,
|
||||||
has_pre_condition_report=False,
|
has_pre_condition_report=False,
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ async def trigger_plan(body: PlanTriggerRequest):
|
||||||
epc_searcher.find_property()
|
epc_searcher.find_property()
|
||||||
# Create a record in db
|
# Create a record in db
|
||||||
property_id, is_new = create_property(
|
property_id, is_new = create_property(
|
||||||
session, body.portfolio_id, epc_searcher.address_clean, epc_searcher.postcode_clean
|
session, body.portfolio_id, epc_searcher.address_clean, epc_searcher.postcode_clean, epc_searcher.uprn
|
||||||
)
|
)
|
||||||
# if a new record was not created, we don't produduce recommendations
|
# if a new record was not created, we don't produduce recommendations
|
||||||
if not is_new:
|
if not is_new:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue