Skip to content

Commit

Permalink
admin/overview: Show some statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
spycrab committed Apr 7, 2019
1 parent fe634e7 commit a78435b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions admin/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{% block content %}
<h3>Welcome, {{ username }}!</h3>

<p>
There {% if session_count == 1 %}is{% else %}are{% end %} currently <i>{{ session_count }}</i> active session{% if session_count != 1 %}s{% end %} with <i>{{ total_player_count }}</i> active player{% if total_player_count != 1 %}s{% end %}.
</p>

Actions:
<ul>
<li>
Expand Down
15 changes: 15 additions & 0 deletions admin/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@

from admin.base import AdminHandler

import api

# pylint: disable=W0223
class Handler(AdminHandler):
"""Handle admin overview"""

def template_args(self):
"""Additional template arguments"""

total_player_count = 0

for secret in api.SESSIONS:
total_player_count += api.SESSIONS[secret]['player_count']

return {
"session_count": len(api.SESSIONS),
"total_player_count": total_player_count
}

def view(self):
"""View to display"""
return "overview"

0 comments on commit a78435b

Please sign in to comment.