forked from Minecraft/minecraft_manager
Overview improvements
parent
76e6084b5b
commit
b44f49239b
21
overview.py
21
overview.py
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
from django.conf import settings
|
||||
from minecraft_manager.models import Application, Player, Ticket, Warning, IP
|
||||
|
||||
|
@ -41,12 +42,24 @@ def overview_data():
|
|||
data['total']['application']['all'] if data['total']['application']['all'] != 0 else 1, 2)
|
||||
}
|
||||
|
||||
# Ratios
|
||||
data['ratio'] = {
|
||||
# Percentage
|
||||
data['percentage'] = {
|
||||
'accepted': round((data['total']['application']['accepted'] /
|
||||
data['total']['application']['denied'] if data['total']['application']['denied'] != 0 else 1) * 100, 2),
|
||||
data['total']['application']['all'] if data['total']['application']['all'] != 0 else 1) * 100, 2),
|
||||
'banned': round((data['total']['player']['banned'] /
|
||||
data['total']['player']['unbanned'] if data['total']['player']['unbanned'] != 0 else 1) * 100, 2)
|
||||
data['total']['player']['all'] if data['total']['player']['all'] != 0 else 1) * 100, 2),
|
||||
'applied': round((data['total']['application']['all'] / data['total']['player']['all']) * 100, 2)
|
||||
}
|
||||
|
||||
# Unique logins
|
||||
now = datetime.now()
|
||||
day = now - timedelta(days=1)
|
||||
week = now - timedelta(weeks=1)
|
||||
month = now - timedelta(weeks=4)
|
||||
data['unique'] = {
|
||||
'day': Player.objects.filter(last_seen__range=[day, now]).count(),
|
||||
'week': Player.objects.filter(last_seen__range=[week, now]).count(),
|
||||
'month': Player.objects.filter(last_seen__range=[month, now]).count()
|
||||
}
|
||||
|
||||
return data
|
||||
|
|
|
@ -40,10 +40,21 @@
|
|||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-xs-9 col-md-6">
|
||||
<h3>Acceptance Rate: {{ data.ratio.accepted }}%</h3>
|
||||
<h3>Acceptance Rate: {{ data.percentage.accepted }}%</h3>
|
||||
<h3>Application/Player Rate: {{ data.percentage.applied }}%</h3>
|
||||
</div>
|
||||
<div class="col-xs-9 col-md-6">
|
||||
<h3>Ban Rate: {{ data.ratio.banned }}%</h3>
|
||||
<h3>Ban Rate: {{ data.percentage.banned }}%</h3>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-xs-9 col-md-6">
|
||||
<h3>Logins Today: {{ data.unique.day }}</h3>
|
||||
<h3>Logins Last Month: {{ data.unique.month }}</h3>
|
||||
</div>
|
||||
<div class="col-xs-9 col-md-6">
|
||||
<h3>Logins Last Week: {{ data.unique.week }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue