Don't use get_latest_server_stats

Use get_server_stats_by_id instead of get_latest_server_stats

The reasoning behind this is that all usages of get_latest_server_stats
had `DatabaseShortcuts.return_rows(latest)[0]`, which
get_server_stats_by_id already did
This commit is contained in:
luukas 2022-05-25 14:43:05 +03:00
parent 166272e12c
commit 4b707aa9d1
No known key found for this signature in database
GPG Key ID: CC4915E8D71FC044
3 changed files with 7 additions and 10 deletions

View File

@ -107,11 +107,11 @@ class ServerPermsController:
)
for server in authorized_servers:
latest = HelperServerStats.get_latest_server_stats(server.get("server_id"))
latest = HelperServerStats.get_server_stats_by_id(server.get("server_id"))
server_data.append(
{
"server_data": server,
"stats": DatabaseShortcuts.return_rows(latest)[0],
"stats": latest,
}
)
return server_data

View File

@ -153,7 +153,7 @@ class ServersController:
)
for server in authorized_servers:
latest = HelperServerStats.get_latest_server_stats(server.get("server_id"))
latest = HelperServerStats.get_server_stats_by_id(server.get("server_id"))
key_permissions = PermissionsServers.get_api_key_permissions_list(
api_key, server.get("server_id")
)
@ -164,7 +164,7 @@ class ServersController:
server_data.append(
{
"server_data": server,
"stats": DatabaseShortcuts.return_rows(latest)[0],
"stats": latest,
"user_command_permission": user_command_permission,
}
)
@ -176,7 +176,7 @@ class ServersController:
authorized_servers = ServersController.get_authorized_servers(user_id)
for server in authorized_servers:
latest = HelperServerStats.get_latest_server_stats(server.get("server_id"))
latest = HelperServerStats.get_server_stats_by_id(server.get("server_id"))
# TODO
user_permissions = PermissionsServers.get_user_id_permissions_list(
user_id, server.get("server_id")
@ -188,7 +188,7 @@ class ServersController:
server_data.append(
{
"server_data": server,
"stats": DatabaseShortcuts.return_rows(latest)[0],
"stats": latest,
"user_command_permission": user_command_permission,
}
)

View File

@ -1,5 +1,4 @@
import logging
from playhouse.shortcuts import model_to_dict
from app.classes.models.server_stats import HelperServerStats
from app.classes.web.base_api_handler import BaseApiHandler
@ -21,8 +20,6 @@ class ApiServersServerStatsHandler(BaseApiHandler):
200,
{
"status": "ok",
"data": model_to_dict(
HelperServerStats.get_latest_server_stats(server_id)[0]
),
"data": HelperServerStats.get_server_stats_by_id(server_id),
},
)