Added property id to plan creation

This commit is contained in:
Khalim Conn-Kowlessar 2023-08-16 12:10:24 +01:00
parent 557aa108e5
commit 560af9e0cf
2 changed files with 3 additions and 0 deletions

View file

@ -44,6 +44,7 @@ class Plan(Base):
id = Column(BigInteger, primary_key=True, autoincrement=True)
portfolio_id = Column(BigInteger, ForeignKey(Portfolio.id), nullable=False)
property_id = Column(BigInteger, ForeignKey(PropertyModel.id), nullable=False)
created_at = Column(TIMESTAMP, nullable=False, server_default=func.now())
is_default = Column(Boolean, nullable=False)

View file

@ -245,6 +245,7 @@ async def trigger_plan(body: PlanTriggerRequest):
# 2) the property details (epc)
# 3) the recommendations
logger.info("Uploading recommendations to the database")
# Upload property data
for p in input_properties:
property_details_epc = p.get_property_details_epc(portfolio_id=body.portfolio_id, rating_lookup=rating_lookup)
@ -265,6 +266,7 @@ async def trigger_plan(body: PlanTriggerRequest):
new_plan_id = create_plan(
{
"portfolio_id": body.portfolio_id,
"property_id": p.id,
"is_default": True
}
)