mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-31 21:06:10 +01:00
Fix metrics schedule lag
This commit is contained in:
parent
cb1490724c
commit
7f412954d7
@ -106,11 +106,9 @@ class ServersController(metaclass=Singleton):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
def get_history_stats(self, server_id):
|
def get_history_stats(self, server_id):
|
||||||
max_age = self.helper.get_setting("history_max_age")
|
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
minimum_to_exist = now - datetime.timedelta(days=max_age)
|
|
||||||
srv = ServersController().get_server_instance_by_id(server_id)
|
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
|
@staticmethod
|
||||||
def update_unloaded_server(server_obj):
|
def update_unloaded_server(server_obj):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
from app.classes.models.servers import Servers, HelperServers
|
from app.classes.models.servers import Servers, HelperServers
|
||||||
from app.classes.shared.helpers import Helpers
|
from app.classes.shared.helpers import Helpers
|
||||||
@ -137,7 +138,8 @@ class HelperServerStats:
|
|||||||
)
|
)
|
||||||
return server_data
|
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 (
|
return (
|
||||||
ServerStats.select()
|
ServerStats.select()
|
||||||
.where(ServerStats.created > max_age)
|
.where(ServerStats.created > max_age)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user