From f643f428eae614956106c39842493768d4270b5f Mon Sep 17 00:00:00 2001 From: aronwk-aaron Date: Thu, 17 Nov 2022 22:41:43 -0600 Subject: [PATCH] apeed up about page loading add some neat info --- app/main.py | 18 ++++++++++++--- app/templates/main/about.html.j2 | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index 76c0d77..6ac54a6 100644 --- a/app/main.py +++ b/app/main.py @@ -4,6 +4,9 @@ from flask_user import current_user, login_required from app.models import Account, CharacterInfo, ActivityLog from app.schemas import AccountSchema, CharacterInfoSchema +import datetime +import time + main_blueprint = Blueprint('main', __name__) account_schema = AccountSchema() @@ -30,10 +33,14 @@ def about(): """About Page""" mods = Account.query.filter(Account.gm_level > 0).order_by(Account.gm_level.desc()).all() online = 0 - chars = CharacterInfo.query.all() + users = [] + zones = {} + twodaysago = time.mktime((datetime.datetime.now() - datetime.timedelta(days=2)).timetuple()) + chars = CharacterInfo.query.filter(CharacterInfo.last_login >= twodaysago).all() + for char in chars: last_log = ActivityLog.query.with_entities( - ActivityLog.activity + ActivityLog.activity, ActivityLog.map_id ).filter( ActivityLog.character_id == char.id ).order_by(ActivityLog.id.desc()).first() @@ -41,8 +48,13 @@ def about(): if last_log: if last_log[0] == 0: online += 1 + if current_user.gm_level >= 8: users.append([char.name, last_log[1]]) + if str(last_log[1]) not in zones: + zones[str(last_log[1])] = 1 + else: + zones[str(last_log[1])] += 1 - return render_template('main/about.html.j2', mods=mods, online=online) + return render_template('main/about.html.j2', mods=mods, online=online, users=users, zones=zones) @main_blueprint.route('/favicon.ico') diff --git a/app/templates/main/about.html.j2 b/app/templates/main/about.html.j2 index 2011d0c..0e297f1 100644 --- a/app/templates/main/about.html.j2 +++ b/app/templates/main/about.html.j2 @@ -4,9 +4,47 @@ {% block content_before %} Online Players: {{ online }} + {% endblock %} {% block content %} + + {# show general zone info to everyone #} + {% if zones %} +
+
+ {% for zone, players in zones.items() %} +
+
+ {{ zone|get_zone_name }} +
+
+ {{ players }} +
+
+ {% endfor %} +
+
+ {% endif %} + + {# only show this info to high level admina #} + {% if current_user.gm_level >= 8 and users|length > 0 %} +
+
+ {% for user in users %} +
+
+ {{ user[0] }} +
+
+ {{ user[1]|get_zone_name }} +
+
+ {% endfor %} +
+
+ {% endif %} +

Staff