fixing property.property and passing task id

This commit is contained in:
Khalim Conn-Kowlessar 2026-03-30 17:51:13 +01:00
parent 1445d2687e
commit 354c8fcb27
3 changed files with 54 additions and 2 deletions

View file

@ -174,6 +174,8 @@ async def trigger_plan_entrypoint(body: PlanTriggerRequest):
service="plan_engine",
inputs=data,
task_only=True,
source=SourceEnum.PORTFOLIO,
source_id=str(body.portfolio_id),
)
subtask_interface = SubTaskInterface()
@ -222,6 +224,8 @@ async def trigger_plan_entrypoint(body: PlanTriggerRequest):
service="plan_engine",
inputs=data,
task_only=False,
source=SourceEnum.PORTFOLIO,
source_id=str(body.portfolio_id),
)
data["task_id"] = str(task_id)
data["subtask_id"] = str(subtask_id)

View file

@ -134,7 +134,7 @@ def handler(event: Mapping[str, Any], context: Optional[Any]) -> Mapping[str, Un
body_dict = {
"task_id": "test",
"subtask_id": "test",
"portfolio_id": 569,
"portfolio_id": 647,
"scenario_ids": [],
"default_plans_only": True,
}
@ -159,6 +159,54 @@ def handler(event: Mapping[str, Any], context: Optional[Any]) -> Mapping[str, Un
with db_read_session() as session:
exported_files = process_export(payload, session)
# Merge with input
raw_input1 = pd.read_excel(
"/Users/khalimconn-kowlessar/Downloads/eon - 20260323 address sanitisation - Standardised.xlsx",
sheet_name="Standardised Asset List",
)
raw_input2 = pd.read_excel(
"/Users/khalimconn-kowlessar/Downloads/eon - 20260323 address sanitisation - Standardised.xlsx",
sheet_name="Addresses needing validation",
)
raw_input = pd.concat([raw_input1, raw_input2], ignore_index=True)
raw_input["epc_os_uprn"] = np.where(
pd.isnull(raw_input["epc_os_uprn"]),
raw_input["ordnance_survey_uprn"],
raw_input["epc_os_uprn"],
)
raw_input["epc_os_uprn"] = raw_input["epc_os_uprn"].astype(int)
left_df = raw_input[
["epc_os_uprn", "domna_address_1", "landlord_property_type", "landlord_property_type"]].copy()
combined = left_df.merge(
exported_files["default_plans"], how="right",
left_on="epc_os_uprn", right_on="uprn"
)
raw_addresses = pd.read_excel(
"/Users/khalimconn-kowlessar/Downloads/North Tyneside Council. EPC D and Below with Type (1).xlsx")
raw_addresses = raw_addresses[["UPRN", "Address 1", "Postcode"]]
raw_addresses["Address 1"] = raw_addresses["Address 1"].str.replace(" ", " ")
raw_addresses = raw_addresses.drop_duplicates("Address 1")
combined2 = combined.merge(
raw_addresses, how="left", left_on="domna_address_1", right_on="Address 1"
)
combined2 = combined2.drop(columns=["landlord_property_id"])
combined2 = combined2.rename(columns={"UPRN": "landlord_property_id"})
combined2["epc_os_uprn"] = combined2["epc_os_uprn"].astype("Int64")
combined2.to_excel("/Users/khalimconn-kowlessar/Downloads/EON - recommended measures for review.xlsx")
removed = raw_addresses[~raw_addresses["UPRN"].isin(combined2["landlord_property_id"])]
df2 = pd.read_excel(
"/Users/khalimconn-kowlessar/Downloads/20260330 EON - recommended measures for review (1).xlsx"
)
removed2 = raw_addresses[~raw_addresses["UPRN"].isin(df2["landlord_property_id"])]
raw_addresses[raw_addresses["Address 1"].duplicated()]
# TODO: Need to handle the exported files - e.g. upload to s3 and email a presigned url
_ = exported_files
return {

View file

@ -209,7 +209,7 @@ class Costs:
# Try and get the region after converting the keys to lower
self.region = {
k.lower(): v for k, v in county_to_region_map.items()
}.get(self.property.property.epc_record.local_authority_label.lower(), None)
}.get(self.property.epc_record.local_authority_label.lower(), None)
if self.region is None:
logger.warning("No region found for county %s, defaulting to South East England",