From d005f6e1e19ae757077e096a5464f47c06fc4db3 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 21 Jul 2020 06:35:47 +0200 Subject: [PATCH] WebHost: fix landing page caching and mention amount of multiworlds in the last week. --- WebHostLib/landing.py | 8 +++++--- WebHostLib/templates/landing.html | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/WebHostLib/landing.py b/WebHostLib/landing.py index 3bc3488b..d06a978d 100644 --- a/WebHostLib/landing.py +++ b/WebHostLib/landing.py @@ -1,8 +1,10 @@ from flask import render_template from WebHostLib import app, cache +from .models import * +from datetime import timedelta - -@cache.memoize(timeout=300) @app.route('/', methods=['GET', 'POST']) +@cache.cached(timeout=300) # cache has to appear under app route for caching to work def landing(): - return render_template("landing.html") + multiworlds = count(room for room in Room if room.creation_time >= datetime.utcnow() - timedelta(days=7)) + return render_template("landing.html", multiworlds=multiworlds) diff --git a/WebHostLib/templates/landing.html b/WebHostLib/templates/landing.html index a58fd524..453bdbad 100644 --- a/WebHostLib/templates/landing.html +++ b/WebHostLib/templates/landing.html @@ -35,6 +35,7 @@

This website is under active development. As such, your hosted rooms may occasionally disappear, and there may be bugs. If you do happen to find a bug, please report it here.

+

{{ multiworlds }} games were started in the last 7 days.