Changing history units to hours

This commit is contained in:
Silversthorn 2023-09-19 21:46:31 +02:00
parent 99ef2db016
commit e9439ca154
4 changed files with 6 additions and 6 deletions

View File

@ -105,9 +105,9 @@ class ServersController(metaclass=Singleton):
return ret
def get_history_stats(self, server_id, days):
def get_history_stats(self, server_id, hours):
srv = ServersController().get_server_instance_by_id(server_id)
return srv.stats_helper.get_history_stats(server_id, days)
return srv.stats_helper.get_history_stats(server_id, hours)
@staticmethod
def update_unloaded_server(server_obj):

View File

@ -142,9 +142,9 @@ class HelperServerStats:
self.database.close()
return server_data
def get_history_stats(self, server_id, num_days):
def get_history_stats(self, server_id, num_hours):
self.database.connect(reuse_if_open=True)
max_age = datetime.datetime.now() - timedelta(days=num_days)
max_age = datetime.datetime.now() - timedelta(hours=num_hours)
query_stats = (
ServerStats.select()
.where(ServerStats.created > max_age)

View File

@ -1814,5 +1814,5 @@ class ServerInstance:
self.stats_helper.remove_old_stats(minimum_to_exist)
def get_server_history(self):
history = self.stats_helper.get_history_stats(self.server_id, 3)
history = self.stats_helper.get_history_stats(self.server_id, 1)
return history

View File

@ -747,7 +747,7 @@ class PanelHandler(BaseHandler):
0, page_data["options"].pop(page_data["options"].index(days))
)
page_data["history_stats"] = self.controller.servers.get_history_stats(
server_id, days
server_id, hours=(days * 24)
)
def get_banned_players_html():