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 @staticmethod
def delete_scheduled_task(schedule_id): def delete_scheduled_task(schedule_id):
sch = Schedules.get(Schedules.schedule_id == schedule_id) return Schedules.delete().where(Schedules.schedule_id == schedule_id).execute()
return Schedules.delete_instance(sch)
@staticmethod @staticmethod
def update_scheduled_task(schedule_id, updates): 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() return Roles.update(up_data).where(Roles.role_id == role_id).execute()
def remove_role(self, role_id): def remove_role(self, role_id):
with self.database.atomic(): return Roles.delete().where(Roles.role_id == role_id).execute()
role = Roles.get(Roles.role_id == role_id)
return role.delete_instance()
@staticmethod @staticmethod
def role_id_exists(role_id): def role_id_exists(role_id):

View File

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

View File

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