mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Calculate the min stats date with timedelta
This is more correct than just using days. I've also tested this working in a completely separate Peewee project.
This commit is contained in:
parent
a937a94ac8
commit
83018c6860
@ -258,6 +258,6 @@ class Stats:
|
||||
# delete old data
|
||||
max_age = self.helper.get_setting("history_max_age")
|
||||
now = datetime.datetime.now()
|
||||
minimum_to_exist = now.day - max_age
|
||||
minimum_to_exist = now - datetime.timedelta(days=max_age)
|
||||
|
||||
HostStats.delete().where(HostStats.time < minimum_to_exist).execute()
|
||||
|
@ -1450,6 +1450,6 @@ class Server:
|
||||
# delete old data
|
||||
max_age = self.helper.get_setting("history_max_age")
|
||||
now = datetime.datetime.now()
|
||||
minimum_to_exist = now.day - max_age
|
||||
minimum_to_exist = now - datetime.timedelta(days=max_age)
|
||||
|
||||
HelperServerStats.remove_old_stats(server.get("id", 0), minimum_to_exist)
|
||||
|
Loading…
Reference in New Issue
Block a user