Fix metrics schedule lag

This commit is contained in:
Andrew 2022-08-30 17:27:19 -04:00
parent cb1490724c
commit 7f412954d7
2 changed files with 4 additions and 4 deletions

View File

@ -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):

View File

@ -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)