mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
recommendaions process working
This commit is contained in:
parent
096915bf33
commit
8596878fc0
2 changed files with 9 additions and 0 deletions
|
|
@ -33,6 +33,12 @@ def create_scenario(session: Session, scenario):
|
|||
:param scenario: dictionary of data representing a scenario to be created
|
||||
"""
|
||||
try:
|
||||
|
||||
# Before creating a new scenario, we check if there is a scenario for this portfolio id already
|
||||
# If there is, it means that any new scnario created will NOT be the default scenario
|
||||
existing_scenario = session.query(Scenario).filter_by(portfolio_id=scenario["portfolio_id"]).first()
|
||||
scenario["is_default"] = True if not existing_scenario else False
|
||||
|
||||
new_scenario = Scenario(**scenario)
|
||||
session.add(new_scenario)
|
||||
session.flush()
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ class Scenario(Base):
|
|||
non_invasive_recommendations_file_path = Column(String)
|
||||
exclusions = Column(String)
|
||||
multi_plan = Column(Boolean, default=False)
|
||||
is_default = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
# Add in the fields we need, which were previously sitting at the portfolio level
|
||||
cost = Column(Float)
|
||||
|
|
@ -107,3 +108,5 @@ class Scenario(Base):
|
|||
cost_per_co2_saved = Column(String)
|
||||
cost_per_sap_point = Column(String)
|
||||
valuation_return_on_investment = Column(String)
|
||||
property_valuation_increase = Column(Float)
|
||||
labour_days = Column(Float)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue