From 7f412954d717f7f4678c37d95820926651139adb Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 30 Aug 2022 17:27:19 -0400 Subject: [PATCH] Fix metrics schedule lag --- app/classes/controllers/servers_controller.py | 4 +--- app/classes/models/server_stats.py | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/classes/controllers/servers_controller.py b/app/classes/controllers/servers_controller.py index a0948769..c9434b13 100644 --- a/app/classes/controllers/servers_controller.py +++ b/app/classes/controllers/servers_controller.py @@ -106,11 +106,9 @@ class ServersController(metaclass=Singleton): return ret def get_history_stats(self, server_id): - max_age = self.helper.get_setting("history_max_age") now = datetime.datetime.now() - minimum_to_exist = now - datetime.timedelta(days=max_age) srv = ServersController().get_server_instance_by_id(server_id) - return srv.stats_helper.get_history_stats(server_id, minimum_to_exist) + return srv.stats_helper.get_history_stats(server_id) @staticmethod def update_unloaded_server(server_obj): diff --git a/app/classes/models/server_stats.py b/app/classes/models/server_stats.py index 6e589ffc..d6c6efdc 100644 --- a/app/classes/models/server_stats.py +++ b/app/classes/models/server_stats.py @@ -1,6 +1,7 @@ import os import logging import datetime +from datetime import timedelta from app.classes.models.servers import Servers, HelperServers from app.classes.shared.helpers import Helpers @@ -137,7 +138,8 @@ class HelperServerStats: ) return server_data - def get_history_stats(self, server_id, max_age): + def get_history_stats(self, server_id): + max_age = datetime.datetime.now() - timedelta(days=1) return ( ServerStats.select() .where(ServerStats.created > max_age)