Make some model removals way more efficient

This commit is contained in:
luukas 2022-05-16 01:18:08 +03:00
parent 65ba65a67d
commit fbf820fd38
4 changed files with 4 additions and 9 deletions

View File

@ -264,8 +264,7 @@ class HelpersManagement:
@staticmethod
def delete_scheduled_task(schedule_id):
sch = Schedules.get(Schedules.schedule_id == schedule_id)
return Schedules.delete_instance(sch)
return Schedules.delete().where(Schedules.schedule_id == schedule_id).execute()
@staticmethod
def update_scheduled_task(schedule_id, updates):

View File

@ -64,9 +64,7 @@ class HelperRoles:
return Roles.update(up_data).where(Roles.role_id == role_id).execute()
def remove_role(self, role_id):
with self.database.atomic():
role = Roles.get(Roles.role_id == role_id)
return role.delete_instance()
return Roles.delete().where(Roles.role_id == role_id).execute()
@staticmethod
def role_id_exists(role_id):

View File

@ -128,7 +128,6 @@ class HelperServers:
return server_obj.save()
def remove_server(self, server_id):
with self.database.atomic():
Servers.delete().where(Servers.server_id == server_id).execute()
@staticmethod

View File

@ -224,8 +224,7 @@ class HelperUsers:
def remove_user(self, user_id):
with self.database.atomic():
UserRoles.delete().where(UserRoles.user_id == user_id).execute()
user = Users.get(Users.user_id == user_id)
return user.delete_instance()
Users.delete().where(Users.user_id == user_id).execute()
@staticmethod
def set_support_path(user_id, support_path):