Fix error where database atomic is not needed

This commit is contained in:
Andrew 2022-05-21 14:26:58 -04:00
parent 2709ebb54b
commit f099639cc6

View File

@ -211,26 +211,23 @@ class HelperServerStats:
@staticmethod
def sever_crashed(server_id):
HelperServerStats.select_database(server_id)
with database_stats_proxy.atomic():
ServerStats.update(crashed=True).where(
ServerStats.server_id == server_id
).execute()
ServerStats.update(crashed=True).where(
ServerStats.server_id == server_id
).execute()
@staticmethod
def set_download(server_id):
HelperServerStats.select_database(server_id)
with database_stats_proxy.atomic():
ServerStats.update(downloading=True).where(
ServerStats.server_id == server_id
).execute()
ServerStats.update(downloading=True).where(
ServerStats.server_id == server_id
).execute()
@staticmethod
def finish_download(server_id):
HelperServerStats.select_database(server_id)
with database_stats_proxy.atomic():
ServerStats.update(downloading=False).where(
ServerStats.server_id == server_id
).execute()
ServerStats.update(downloading=False).where(
ServerStats.server_id == server_id
).execute()
@staticmethod
def get_download_status(server_id):
@ -246,10 +243,9 @@ class HelperServerStats:
return
HelperServerStats.select_database(server_id)
with database_stats_proxy.atomic():
ServerStats.update(crashed=False).where(
ServerStats.server_id == server_id
).execute()
ServerStats.update(crashed=False).where(
ServerStats.server_id == server_id
).execute()
@staticmethod
def is_crashed(server_id):
@ -272,10 +268,9 @@ class HelperServerStats:
ServerStats.select().where(ServerStats.server_id == server_id)
except Exception as ex:
logger.error(f"Database entry not found! {ex}")
with database_stats_proxy.atomic():
ServerStats.update(updating=value).where(
ServerStats.server_id == server_id
).execute()
ServerStats.update(updating=value).where(
ServerStats.server_id == server_id
).execute()
@staticmethod
def get_update_status(server_id):
@ -295,10 +290,9 @@ class HelperServerStats:
except Exception as ex:
logger.error(f"Database entry not found! {ex}")
return
with database_stats_proxy.atomic():
ServerStats.update(first_run=False).where(
ServerStats.server_id == server_id
).execute()
ServerStats.update(first_run=False).where(
ServerStats.server_id == server_id
).execute()
@staticmethod
def get_first_run(server_id):
@ -341,10 +335,9 @@ class HelperServerStats:
ServerStats.select().where(ServerStats.server_id == server_id)
except Exception as ex:
logger.error(f"Database entry not found! {ex}")
with database_stats_proxy.atomic():
ServerStats.update(waiting_start=value).where(
ServerStats.server_id == server_id
).execute()
ServerStats.update(waiting_start=value).where(
ServerStats.server_id == server_id
).execute()
@staticmethod
def get_waiting_start(server_id):