consolidating commits

This commit is contained in:
Khalim Conn-Kowlessar 2023-08-21 11:18:03 +01:00
parent 8f7ae68b4a
commit eef6fd27dd
2 changed files with 6 additions and 4 deletions

View file

@ -10,7 +10,7 @@ def create_plan(session, plan):
new_plan = Plan(**plan)
session.add(new_plan)
session.commit()
session.flush()
return new_plan.id
@ -63,7 +63,6 @@ def create_plan_recommendations(session, plan_id, recommendation_ids):
':recommendation_id)'),
{'plan_id': plan_id, 'recommendation_id': recommendation_id}
)
session.commit()
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)
# Commit all changes
session.commit()
# flush the changes to get the newly created IDs
session.flush()
return uploaded_recommendation_ids

View file

@ -366,6 +366,9 @@ async def trigger_plan(body: PlanTriggerRequest):
# the portfolion level impact
aggregate_portfolio_recommendations(session, portfolio_id=body.portfolio_id)
# Commit all changes at once
session.commit()
session.close()
return Response(status_code=200)