This commit is contained in:
Notoric 2024-06-02 00:51:02 +01:00
commit 4d240a68f4
1 changed files with 4 additions and 2 deletions

View File

@ -260,7 +260,9 @@ def get_all_news():
def delete_old_news(): def delete_old_news():
print("Deleting old news articles...") print("Deleting old news articles...")
db.newsfeed.delete_many({'timestamp': {'$lt': datetime.now() - timedelta(hours=config['news']['article_lifetime']) }}) hrs = int(config['news']['article_lifetime'])
db.newsfeed.delete_many({'timestamp': {'$lt': datetime.now() - timedelta(hours=hrs) }})
print("Old news articles deleted!") print("Old news articles deleted!")
@ -269,7 +271,7 @@ def delete_old_news():
create_collections() create_collections()
schedule.every(5).minutes.do(write_weather) schedule.every(5).minutes.do(write_weather)
schedule.every(config['news']['article_interval']).hours.do(get_all_news) schedule.every(int(config['news']['article_interval'])).hours.do(get_all_news)
schedule.every(1).hours.do(delete_old_news) schedule.every(1).hours.do(delete_old_news)
write_weather() write_weather()