perf(fastapi): removes multiple database write in single endpoint

This commit is contained in:
sauravniraula 2025-07-22 16:44:19 +05:45
parent 470b6472f0
commit fd71bdd125
No known key found for this signature in database
GPG key ID: 60FCC1B5A5E83326

View file

@ -134,11 +134,6 @@ async def prepare_presentation(
with get_sql_session() as sql_session:
presentation = sql_session.get(PresentationModel, presentation_id)
presentation.outlines = [each.model_dump() for each in outlines]
presentation.title = title or presentation.title
presentation.layout = layout.model_dump()
sql_session.commit()
sql_session.refresh(presentation)
total_slide_layouts = len(layout.slides)
total_outlines = len(outlines)
@ -164,6 +159,9 @@ async def prepare_presentation(
with get_sql_session() as sql_session:
sql_session.add(presentation)
presentation.outlines = [each.model_dump() for each in outlines]
presentation.title = title or presentation.title
presentation.set_layout(layout)
presentation.set_structure(presentation_structure)
sql_session.commit()
sql_session.refresh(presentation)