mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
consolidating commits
This commit is contained in:
parent
8f7ae68b4a
commit
eef6fd27dd
2 changed files with 6 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ def create_plan(session, plan):
|
||||||
|
|
||||||
new_plan = Plan(**plan)
|
new_plan = Plan(**plan)
|
||||||
session.add(new_plan)
|
session.add(new_plan)
|
||||||
session.commit()
|
session.flush()
|
||||||
|
|
||||||
return new_plan.id
|
return new_plan.id
|
||||||
|
|
||||||
|
|
@ -63,7 +63,6 @@ def create_plan_recommendations(session, plan_id, recommendation_ids):
|
||||||
':recommendation_id)'),
|
':recommendation_id)'),
|
||||||
{'plan_id': plan_id, 'recommendation_id': recommendation_id}
|
{'plan_id': plan_id, 'recommendation_id': recommendation_id}
|
||||||
)
|
)
|
||||||
session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
def upload_recommendations(session, recommendations_to_upload, property_id):
|
def upload_recommendations(session, recommendations_to_upload, property_id):
|
||||||
|
|
@ -106,7 +105,7 @@ def upload_recommendations(session, recommendations_to_upload, property_id):
|
||||||
|
|
||||||
session.bulk_insert_mappings(RecommendationMaterials, recommendation_materials_data)
|
session.bulk_insert_mappings(RecommendationMaterials, recommendation_materials_data)
|
||||||
|
|
||||||
# Commit all changes
|
# flush the changes to get the newly created IDs
|
||||||
session.commit()
|
session.flush()
|
||||||
|
|
||||||
return uploaded_recommendation_ids
|
return uploaded_recommendation_ids
|
||||||
|
|
|
||||||
|
|
@ -366,6 +366,9 @@ async def trigger_plan(body: PlanTriggerRequest):
|
||||||
# the portfolion level impact
|
# the portfolion level impact
|
||||||
aggregate_portfolio_recommendations(session, portfolio_id=body.portfolio_id)
|
aggregate_portfolio_recommendations(session, portfolio_id=body.portfolio_id)
|
||||||
|
|
||||||
|
# Commit all changes at once
|
||||||
|
session.commit()
|
||||||
|
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
return Response(status_code=200)
|
return Response(status_code=200)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue