mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
finished updating recommendations for now to build portfolios
This commit is contained in:
parent
02b76cd9fe
commit
d942eacc55
5 changed files with 10 additions and 3 deletions
|
|
@ -8,6 +8,7 @@ def aggregate_portfolio_recommendations(session, portfolio_id: int):
|
|||
aggregates = (
|
||||
session.query(
|
||||
func.sum(Recommendation.estimated_cost).label("cost"),
|
||||
func.sum(Recommendation.total_work_hours).label("total_work_hours"),
|
||||
# For future usage we will aggregate multiple fields in this step
|
||||
# func.sum(Recommendation.heat_demand).label("total_heat_demand"),
|
||||
# func.sum(Recommendation.energy_savings).label("total_energy_savings")
|
||||
|
|
@ -20,6 +21,7 @@ def aggregate_portfolio_recommendations(session, portfolio_id: int):
|
|||
|
||||
aggregates_dict = {
|
||||
"cost": aggregates.cost or 0,
|
||||
"total_work_hours": aggregates.total_work_hours or 0,
|
||||
# "total_heat_demand": aggregates.total_heat_demand or 0,
|
||||
# "total_energy_savings": aggregates.total_energy_savings or 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ def upload_recommendations(session: Session, recommendations_to_upload, property
|
|||
"default": rec["default"],
|
||||
"starting_u_value": rec.get("starting_u_value"),
|
||||
"new_u_value": rec.get("new_u_value"),
|
||||
"sap_points": rec["sap_points"]
|
||||
"sap_points": rec["sap_points"],
|
||||
"total_work_hours": rec["labour_hours"],
|
||||
}
|
||||
for rec in recommendations_to_upload
|
||||
]
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ async def trigger_plan(body: PlanTriggerRequest):
|
|||
# the portfolion level impact
|
||||
aggregate_portfolio_recommendations(session, portfolio_id=body.portfolio_id)
|
||||
|
||||
# Commit all changes at once
|
||||
# Commit final changes
|
||||
session.commit()
|
||||
except IntegrityError:
|
||||
logger.error("Database integrity error occurred", exc_info=True)
|
||||
|
|
|
|||
|
|
@ -44,5 +44,7 @@ class FireplaceRecommendations(Definitions):
|
|||
"new_u_value": None,
|
||||
"sap_points": None,
|
||||
"total": estimated_cost,
|
||||
# Take a very basic estimate of 6 hours, multipled by the number of open fireplaces to seal
|
||||
"labour_hours": 6 * number_open_fireplaces
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -61,10 +61,12 @@ class VentilationRecommendations(Definitions):
|
|||
{
|
||||
"parts": part,
|
||||
"type": part[0]["type"],
|
||||
"description": "Install %s" % part[0]["description"],
|
||||
"description": f"Install {n_units} {part[0]['description']} units",
|
||||
"starting_u_value": None,
|
||||
"new_u_value": None,
|
||||
"sap_points": None,
|
||||
"total": estimated_cost,
|
||||
# We use a very simple and rough estimate of 4 hours per unit
|
||||
"labour_hours": 4 * n_units
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue