1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Force refresh of updated_at value in db models.

This commit is contained in:
grossmj 2021-06-01 16:09:29 +09:30
parent a6c2a3e47f
commit 0113ca6673
3 changed files with 21 additions and 13 deletions

View File

@ -81,12 +81,14 @@ class ComputesRepository(BaseRepository):
query = update(models.Compute).\
where(models.Compute.compute_id == compute_id).\
values(update_values).\
execution_options(synchronize_session="fetch")
values(update_values)
await self._db_session.execute(query)
await self._db_session.commit()
return await self.get_compute(compute_id)
compute_db = await self.get_compute(compute_id)
if compute_db:
await self._db_session.refresh(compute_db) # force refresh of updated_at value
return compute_db
async def delete_compute(self, compute_id: UUID) -> bool:

View File

@ -70,14 +70,16 @@ class TemplatesRepository(BaseRepository):
update_values = template_update.dict(exclude_unset=True)
query = not update(models.Template). \
query = update(models.Template). \
where(models.Template.template_id == template_id). \
values(update_values).\
execution_options(synchronize_session="fetch")
values(update_values)
await self._db_session.execute(query)
await self._db_session.commit()
return await self.get_template(template_id)
template_db = await self.get_template(template_id)
if template_db:
await self._db_session.refresh(template_db) # force refresh of updated_at value
return template_db
async def delete_template(self, template_id: UUID) -> bool:

View File

@ -82,12 +82,14 @@ class UsersRepository(BaseRepository):
query = update(models.User).\
where(models.User.user_id == user_id).\
values(update_values).\
execution_options(synchronize_session="fetch")
values(update_values)
await self._db_session.execute(query)
await self._db_session.commit()
return await self.get_user(user_id)
user_db = await self.get_user(user_id)
if user_db:
await self._db_session.refresh(user_db) # force refresh of updated_at value
return user_db
async def delete_user(self, user_id: UUID) -> bool:
@ -156,12 +158,14 @@ class UsersRepository(BaseRepository):
update_values = user_group_update.dict(exclude_unset=True)
query = update(models.UserGroup).\
where(models.UserGroup.user_group_id == user_group_id).\
values(update_values).\
execution_options(synchronize_session="fetch")
values(update_values)
await self._db_session.execute(query)
await self._db_session.commit()
return await self.get_user_group(user_group_id)
user_group_db = await self.get_user_group(user_group_id)
if user_group_db:
await self._db_session.refresh(user_group_db) # force refresh of updated_at value
return user_group_db
async def delete_user_group(self, user_group_id: UUID) -> bool: