gabcares commited on
Commit
fa6d9f4
·
verified ·
1 Parent(s): f516d59

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +2 -3
main.py CHANGED
@@ -177,7 +177,6 @@ async def sms_posts(instance: ResultItem, idx: str = None, action: str = "add")
177
  async with AsyncSession(sms_resource["engine"]) as session:
178
  code = 1
179
  error = None
180
- result = instance.model_copy(deep=True)
181
  existing = await session.get(instance.__class__, idx)
182
 
183
  # For add action, do db operation if instance is not existing. Other actions, do db operation if instance exists in db
@@ -186,7 +185,7 @@ async def sms_posts(instance: ResultItem, idx: str = None, action: str = "add")
186
  try:
187
  if checker:
188
  if action == "delete":
189
- await session.delete(instance)
190
  await session.commit()
191
  else: # add or update use add
192
  session.add(instance) # Not asynchronous
@@ -197,7 +196,7 @@ async def sms_posts(instance: ResultItem, idx: str = None, action: str = "add")
197
  error = e
198
 
199
  finally:
200
- return await endpoint_output(result, code, error)
201
 
202
 
203
  # @cache(expire=ONE_DAY_SEC, namespace='sms_gets') # Cache for 1 day
 
177
  async with AsyncSession(sms_resource["engine"]) as session:
178
  code = 1
179
  error = None
 
180
  existing = await session.get(instance.__class__, idx)
181
 
182
  # For add action, do db operation if instance is not existing. Other actions, do db operation if instance exists in db
 
185
  try:
186
  if checker:
187
  if action == "delete":
188
+ session.delete(instance)
189
  await session.commit()
190
  else: # add or update use add
191
  session.add(instance) # Not asynchronous
 
196
  error = e
197
 
198
  finally:
199
+ return await endpoint_output(instance, code, error)
200
 
201
 
202
  # @cache(expire=ONE_DAY_SEC, namespace='sms_gets') # Cache for 1 day