Make model *_exists functions way more efficient

This commit is contained in:
luukas
2022-05-16 01:12:03 +03:00
parent 0115421243
commit 65ba65a67d
3 changed files with 3 additions and 9 deletions

View File

@ -70,6 +70,4 @@ class HelperRoles:
@staticmethod @staticmethod
def role_id_exists(role_id): def role_id_exists(role_id):
if not HelperRoles.get_role(role_id): return Roles.select().where(Roles.role_id == role_id).count() != 0
return False
return True

View File

@ -205,9 +205,7 @@ class HelperServers:
@staticmethod @staticmethod
def server_id_exists(server_id): def server_id_exists(server_id):
if not HelperServers.get_server_data_by_id(server_id): return Servers.select().where(Servers.server_id == server_id).count() != 0
return False
return True
@staticmethod @staticmethod
def sever_crashed(server_id): def sever_crashed(server_id):

View File

@ -249,9 +249,7 @@ class HelperUsers:
@staticmethod @staticmethod
def user_id_exists(user_id): def user_id_exists(user_id):
if not HelperUsers.get_user(user_id): return Users.select().where(Users.user_id == user_id).count() != 0
return False
return True
# ********************************************************************************** # **********************************************************************************
# User_Roles Methods # User_Roles Methods