Merge branch 'bug/server-stats-refresh' into 'dev'

Make call to controller and not stale object

See merge request crafty-controller/crafty-4!315
This commit is contained in:
Andrew 2022-06-11 21:51:35 +00:00
commit 51697039cd
2 changed files with 9 additions and 4 deletions

View File

@ -273,7 +273,9 @@ class ServersController(metaclass=Singleton):
latest = srv.stats_helper.get_latest_server_stats()
server_data.append(
{
"server_data": server["server_data_obj"],
"server_data": ServersController.get_server_data_by_id(
server.get("server_id")
),
"stats": latest,
"user_command_permission": True,
}
@ -328,7 +330,9 @@ class ServersController(metaclass=Singleton):
user_command_permission = False
server_data.append(
{
"server_data": DatabaseShortcuts.get_data_obj(server.server_object),
"server_data": ServersController.get_server_data_by_id(
server.server_id
),
"stats": latest,
"user_command_permission": user_command_permission,
}

View File

@ -17,6 +17,7 @@ from tornado import iostream
from tzlocal import get_localzone
from croniter import croniter
from app.classes.controllers.roles_controller import RolesController
from app.classes.controllers.servers_controller import ServersController
from app.classes.models.servers import Servers
from app.classes.models.server_permissions import EnumPermissionsServer
@ -258,7 +259,7 @@ class PanelHandler(BaseHandler):
for server in defined_servers[:]:
if str(server.server_id) == str(server_id):
page_servers.append(
DatabaseShortcuts.get_data_obj(server.server_object)
ServersController.get_server_data_by_id(server.server_id)
)
user_order.remove(server_id)
defined_servers.remove(server)
@ -267,7 +268,7 @@ class PanelHandler(BaseHandler):
server_ids.append(str(server.server_id))
if server not in page_servers:
page_servers.append(
DatabaseShortcuts.get_data_obj(server.server_object)
ServersController.get_server_data_by_id(server.server_id)
)
for server_id in user_order[:]: