gets all logs from past hour rather than past 300 logs

This commit is contained in:
2025-09-05 21:00:05 +02:00
parent 89f5c4ef0b
commit 7c5e15af99

View File

@@ -46,14 +46,15 @@ def homepage():
@bp.route("/chart/<int:id>") @bp.route("/chart/<int:id>")
def chart(id: int): def chart(id: int):
one_hour_ago = datetime.now(timezone.utc) - timedelta(hours=1)
with app.app_context(): with app.app_context():
logs = [] logs = []
s = db.session.query(service).filter_by(id=id).first() s = db.session.query(service).filter_by(id=id).first()
if s: if s:
logs = cast( logs = cast(
list[log], list[log],
s.logs.order_by(log.dateCreated.desc()) # type: ignore s.logs.filter(log.dateCreated >= one_hour_ago)
.limit(300) .order_by(log.dateCreated.desc()) # type: ignore
.all(), .all(),
) )
else: else: