added plan name to export

This commit is contained in:
Khalim Conn-Kowlessar 2026-02-25 13:36:02 +00:00
parent 0333f33123
commit 3d18827961
2 changed files with 5 additions and 3 deletions

View file

@ -150,6 +150,7 @@ class DbMethods:
self.session.query(
Recommendation,
PlanModel.scenario_id,
PlanModel.name
)
.join(
PlanRecommendations,
@ -171,6 +172,7 @@ class DbMethods:
for col in Recommendation.__table__.columns
},
"scenario_id": r.scenario_id,
"plan_name": r.name,
}
for r in recs_query
]

View file

@ -59,17 +59,17 @@ def process_export(payload: ExportRequest, session: Session) -> Dict[Union[str,
continue
measures_df: pd.DataFrame = scenario_recs[
["property_id", "measure_type", "estimated_cost"]
["property_id", "measure_type", "plan_name", "estimated_cost"]
].drop_duplicates()
pivot = measures_df.pivot(
index="property_id",
index=["property_id", "plan_name"],
columns="measure_type",
values="estimated_cost",
).reset_index()
pivot["total_retrofit_cost"] = (
pivot.drop(columns=["property_id"]).sum(axis=1)
pivot.drop(columns=["property_id", "plan_name"]).sum(axis=1)
)
post_sap = (