From fb979eda9427355c0fc8d1d981643c9adc799e40 Mon Sep 17 00:00:00 2001 From: Hemna Date: Tue, 30 Mar 2021 10:18:56 -0400 Subject: [PATCH] Provide an initial datapoint on rendering index This patch adds a single data point when rendering the initial stats for the index page. --- aprsd/flask.py | 11 ++++++++--- aprsd/web/templates/index.html | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/aprsd/flask.py b/aprsd/flask.py index 4898742..1b5db92 100644 --- a/aprsd/flask.py +++ b/aprsd/flask.py @@ -43,7 +43,8 @@ class APRSDFlask(flask_classful.FlaskView): @auth.login_required def index(self): - return flask.render_template("index.html", message=self.stats()) + stats = self._stats() + return flask.render_template("index.html", initial_stats=stats) @auth.login_required def messages(self): @@ -69,7 +70,7 @@ class APRSDFlask(flask_classful.FlaskView): track.save() return json.dumps({"messages": "saved"}) - def stats(self): + def _stats(self): stats_obj = stats.APRSDStats() track = messaging.MsgTrack() now = datetime.datetime.now() @@ -84,7 +85,11 @@ class APRSDFlask(flask_classful.FlaskView): "memory_current": current, "memory_peak": peak, } - return json.dumps(result) + + return result + + def stats(self): + return json.dumps(self._stats()) def init_flask(config): diff --git a/aprsd/web/templates/index.html b/aprsd/web/templates/index.html index aba197d..96d851a 100644 --- a/aprsd/web/templates/index.html +++ b/aprsd/web/templates/index.html @@ -12,6 +12,8 @@