Changed properties to social housing homes for birmingham pilot

This commit is contained in:
Khalim Conn-Kowlessar 2023-12-05 12:12:12 +00:00
parent 195578a1aa
commit a45164e29e
3 changed files with 70 additions and 51 deletions

View file

@ -492,38 +492,38 @@ async def trigger_plan(body: PlanTriggerRequest):
for p in batch_properties:
# Your existing operations
# property_details_epc = p.get_property_details_epc(
# portfolio_id=body.portfolio_id, rating_lookup=rating_lookup
# )
# create_property_details_epc(session, property_details_epc)
#
# update_or_create_property_spatial_details(session, p.uprn, p.spatial)
#
# # TODO: TEMP
# if p.data["uprn"] == "":
# print("Get rid of me!")
# p.data["uprn"] = 0
#
# property_data = p.get_full_property_data()
# update_property_data(
# session, property_id=p.id, portfolio_id=body.portfolio_id, property_data=property_data
# )
#
property_details_epc = p.get_property_details_epc(
portfolio_id=body.portfolio_id, rating_lookup=rating_lookup
)
create_property_details_epc(session, property_details_epc)
update_or_create_property_spatial_details(session, p.uprn, p.spatial)
# TODO: TEMP
if p.data["uprn"] == "":
print("Get rid of me!")
p.data["uprn"] = 0
property_data = p.get_full_property_data()
update_property_data(
session, property_id=p.id, portfolio_id=body.portfolio_id, property_data=property_data
)
recommendations_to_upload = recommendations.get(p.id, [])
# if not recommendations_to_upload:
# continue
#
# new_plan_id = create_plan(session, {
# "portfolio_id": body.portfolio_id,
# "property_id": p.id,
# "is_default": True
# })
#
# uploaded_recommendation_ids = upload_recommendations(session, recommendations_to_upload, p.id)
#
# create_plan_recommendations(
# session, plan_id=new_plan_id, recommendation_ids=uploaded_recommendation_ids
# )
if not recommendations_to_upload:
continue
new_plan_id = create_plan(session, {
"portfolio_id": body.portfolio_id,
"property_id": p.id,
"is_default": True
})
uploaded_recommendation_ids = upload_recommendations(session, recommendations_to_upload, p.id)
create_plan_recommendations(
session, plan_id=new_plan_id, recommendation_ids=uploaded_recommendation_ids
)
# Get defaults
default_recommendations = [r for r in recommendations_to_upload if r["default"]]

View file

@ -10,7 +10,7 @@ class PropertyValuation:
15038202: 202000,
37024763: 213000,
100070478545: 212000,
100070297696: 235000,
100070297696: 662000, # Based on Zoopla's estimation of nearby house, 8 bloomfield road
100070476394: 222000, # Based on Zoopla's estimation of next door, 20 Parkside
100071264896: 128000,
# Based on next door neighbour: https://themovemarket.com/tools/propertyprices/flat-2-queens-wood-house-219

View file

@ -42,10 +42,15 @@ def app():
example_1_reponse_filtered = [
x for x in example_1_reponse_filtered if "pitched, no insulation (assumed)" in x["roof-description"].lower()
]
# Get a social housing property
example_1_reponse_filtered = [
x for x in example_1_reponse_filtered if x["tenure"] == "Rented (social)"
]
print(example_1_reponse_filtered[0]["postcode"])
# 21 Penshaw Grove
# B13 9LT
print(example_1_reponse_filtered[0]["address1"])
# B13 9NL
# 113 Tenby Road
print(example_1_reponse_filtered[0]["built-form"])
# Mid-Terrace
print(example_1_reponse_filtered[0]["current-energy-rating"])
@ -74,11 +79,15 @@ def app():
example_2_reponse_filtered = [
x for x in example_2_reponse_filtered if "pitched, 100 mm loft insulation" in x["roof-description"].lower()
]
# Get a social housing property
example_2_reponse_filtered = [
x for x in example_2_reponse_filtered if x["tenure"] == "Rented (social)"
]
print(example_2_reponse_filtered[0]["postcode"])
# B13 9BY
# B28 8JF
print(example_2_reponse_filtered[0]["address1"])
# 2 Bloomfield Road
# 139 School Road
print(example_2_reponse_filtered[0]["built-form"])
# Semi-Detached
print(example_2_reponse_filtered[0]["current-energy-rating"])
@ -96,15 +105,20 @@ def app():
size=1000
)
example_3_reponse = example_3_reponse["rows"]
print(example_3_reponse[2]["walls-description"])
print(example_3_reponse[2]["floor-description"])
print(example_3_reponse[3]["roof-description"])
print(example_3_reponse[3]["postcode"])
# B32 3DG
print(example_3_reponse[3]["address1"])
# 18 Parkside
print(example_3_reponse[3]["built-form"])
# End-Terrace
# Get a social housing property]
example_3_reponse_filtered = [
x for x in example_3_reponse if x["tenure"] == "Rented (social)"
]
print(example_3_reponse_filtered[4]["walls-description"])
print(example_3_reponse_filtered[4]["floor-description"])
print(example_3_reponse_filtered[4]["roof-description"])
print(example_3_reponse_filtered[4]["postcode"])
# B32 1SL
print(example_3_reponse_filtered[4]["address1"])
# 77 Simmons Drive
print(example_3_reponse_filtered[4]["built-form"])
# Semi-Detached
# ~~~~~~~~~~~~~~~~~~~~
# Final example
@ -124,10 +138,14 @@ def app():
x for x in example_4_reponse if
"cavity wall, as built, no insulation (assumed)" in x["walls-description"].lower()
]
# Get a social housing property
example_4_reponse_filtered = [
x for x in example_4_reponse_filtered if x["tenure"] == "Rented (social)"
]
print(example_4_reponse_filtered[0]["postcode"])
# B14 6PU
# B32 1LS
print(example_4_reponse_filtered[0]["address1"])
# Flat 3
# Flat 2
print(example_4_reponse_filtered[0]["floor-description"])
print(example_4_reponse_filtered[0]["property-type"])
@ -135,10 +153,11 @@ def app():
test_file = pd.DataFrame(
[
{"address": "21 Penshaw Grove", "postcode": "B13 9NL", "Notes": None},
{"address": "2 Bloomfield Road", "postcode": "B13 9BY", "Notes": None},
{"address": "18 Parkside", "postcode": "B32 3DG", "Notes": None},
{"address": "Flat 3", "postcode": "B14 6PU", "Notes": None},
# New properties
{"address": "113 Tenby Road", "postcode": "B13 9LT", "Notes": None},
{"address": "139 School Road", "postcode": "B28 8JF", "Notes": None},
{"address": "77 Simmons Drive", "postcode": "B32 1SL", "Notes": None},
{"address": "Flat 2, 54 Wedgewood Road", "postcode": "B32 1LS", "Notes": None},
]
)