mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
debugging
This commit is contained in:
parent
cc6277c191
commit
83d472a710
3 changed files with 30 additions and 6 deletions
|
|
@ -45,6 +45,21 @@ class Portfolio(Base):
|
|||
labour_days = Column(Float)
|
||||
created_at = Column(DateTime, nullable=False, default=datetime.datetime.now(pytz.utc))
|
||||
updated_at = Column(DateTime, nullable=False, default=datetime.datetime.now(pytz.utc))
|
||||
# Aggregations for summary
|
||||
epc_breakdown_pre_retrofit = Column(Text)
|
||||
epc_breakdown_post_retrofit = Column(Text)
|
||||
n_units_to_retrofit = Column(Integer)
|
||||
co2_per_unit_pre_retrofit = Column(Text)
|
||||
co2_per_unit_post_retrofit = Column(Text)
|
||||
energy_bill_per_unit_pre_retrofit = Column(Text)
|
||||
energy_bill_per_unit_post_retrofit = Column(Text)
|
||||
energy_consumption_per_unit_pre_retrofit = Column(Text)
|
||||
energy_consumption_per_unit_post_retrofit = Column(Text)
|
||||
valuation_improvement_per_unit = Column(Text)
|
||||
cost_per_unit = Column(Text)
|
||||
cost_per_co2_saved = Column(Text)
|
||||
cost_per_sap_point = Column(Text)
|
||||
valuation_return_on_investment = Column(Text)
|
||||
|
||||
|
||||
class PropertyCreationStatus(enum.Enum):
|
||||
|
|
|
|||
|
|
@ -99,10 +99,9 @@ def extract_portfolio_aggregation_data(
|
|||
|
||||
agg_data = []
|
||||
for p in input_properties:
|
||||
# Get the recommendations for the property
|
||||
# Get the recommendations for the property - we include all properties, even ones without recommendations
|
||||
property_recommendations = recommendations.get(p.id, [])
|
||||
if not property_recommendations:
|
||||
continue
|
||||
|
||||
# Get just the default recommendations
|
||||
default_recommendations = [r for r in property_recommendations if r["default"]]
|
||||
|
||||
|
|
@ -113,11 +112,16 @@ def extract_portfolio_aggregation_data(
|
|||
post_retrofit_co2 = pre_retrofit_co2 - carbon_savings
|
||||
|
||||
pre_retrofit_energy_bill = p.current_energy_bill
|
||||
post_retrofit_energy_bill = p.expected_energy_bill
|
||||
post_retrofit_energy_bill = p.current_energy_bill - sum(
|
||||
[r["energy_cost_savings"] for r in default_recommendations]
|
||||
)
|
||||
|
||||
pre_retrofit_energy_consumption = p.current_adjusted_energy
|
||||
post_retrofit_energy_consumption = p.expected_adjusted_energy
|
||||
post_retrofit_energy_consumption = p.current_adjusted_energy - sum(
|
||||
[r["adjusted_heat_demand"] for r in default_recommendations]
|
||||
)
|
||||
|
||||
# Add up energy savings
|
||||
cost = sum([r["total"] for r in default_recommendations])
|
||||
sap_point_improvement = sum([r["sap_points"] for r in default_recommendations])
|
||||
|
||||
|
|
@ -166,7 +170,9 @@ def extract_portfolio_aggregation_data(
|
|||
"valuation_improvement_per_unit": format_money(valuation_improvment_per_unit),
|
||||
"cost_per_unit": format_money(agg_data["cost"].mean()),
|
||||
"cost_per_co2_saved": format_money(agg_data["cost"].sum() / total_carbon_saved),
|
||||
"cost_per_sap_point": format_money(agg_data["cost"].sum() / total_sap_points)
|
||||
"cost_per_sap_point": format_money(agg_data["cost"].sum() / total_sap_points),
|
||||
"valuation_return_on_investment": str(round(total_valuation_increase / agg_data["cost"].sum(), 2))
|
||||
# TODO: Could we add 10yr carbon credits value?
|
||||
}
|
||||
|
||||
return aggregation_data
|
||||
|
|
|
|||
|
|
@ -272,6 +272,8 @@ class Recommendations:
|
|||
current_epc_rating=property_instance.data["current-energy-rating"],
|
||||
)
|
||||
|
||||
# TODO: This isn't quite right as this is based on EVERY possible measure, not just the ones that are
|
||||
# actually implemented
|
||||
expected_adjusted_energy = AnnualBillSavings.adjust_energy_to_metered(
|
||||
epc_energy_consumption=expected_heat_demand,
|
||||
current_epc_rating=property_instance.data["current-energy-rating"],
|
||||
|
|
@ -281,6 +283,7 @@ class Recommendations:
|
|||
current_adjusted_energy - expected_adjusted_energy
|
||||
)
|
||||
|
||||
# TODO: We should determine if the home is gas & electricity or just electricity
|
||||
current_energy_bill = AnnualBillSavings.calculate_annual_bill(current_adjusted_energy)
|
||||
expected_energy_bill = AnnualBillSavings.calculate_annual_bill(expected_adjusted_energy)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue