Show the average, min and max player stats for each server.
This commit is contained in:
parent
f5a0ad7396
commit
3937b92835
@ -16,5 +16,17 @@ class ServerDetailView(generic.DetailView):
|
|||||||
history = PlayerHistory()
|
history = PlayerHistory()
|
||||||
points = history.get_points(server)
|
points = history.get_points(server)
|
||||||
context['player_history'] = points
|
context['player_history'] = points
|
||||||
|
|
||||||
|
# Moving average for the last day
|
||||||
|
# TODO: remove the hardcoded value
|
||||||
|
tmp = [players for time, players in points[-96:]]
|
||||||
|
context['daily_average'] = sum(tmp) / float(len(tmp))
|
||||||
|
context['daily_min'] = min(tmp)
|
||||||
|
context['daily_max'] = max(tmp)
|
||||||
|
|
||||||
|
tmp = [players for time, players in points]
|
||||||
|
context['total_average'] = sum(tmp) / float(len(tmp))
|
||||||
|
context['total_min'] = min(tmp)
|
||||||
|
context['total_max'] = max(tmp)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
@ -17,11 +17,35 @@
|
|||||||
<button class="btn btn-default">No homepage</button>
|
<button class="btn btn-default">No homepage</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2>Server History</h2>
|
<h2>Player Population</h2>
|
||||||
|
<p>Currently online: {{server.current_players}} players</p>
|
||||||
<p>Last updated <span title="{{server.last_updated|date:'r'}} GMT">
|
<p>Last updated <span title="{{server.last_updated|date:'r'}} GMT">
|
||||||
{{server.last_updated|timesince}}
|
{{server.last_updated|timesince}}
|
||||||
</span>ago.</p>
|
</span>ago.</p>
|
||||||
<p>Online players: {{server.current_players}}</p>
|
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>Average</th>
|
||||||
|
<th>Min</th>
|
||||||
|
<th>Max</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Daily</th>
|
||||||
|
<th>{{daily_average|floatformat}}</th>
|
||||||
|
<th>{{daily_min}}</th>
|
||||||
|
<th>{{daily_max}}</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Total</th>
|
||||||
|
<th>{{total_average|floatformat}}</th>
|
||||||
|
<th>{{total_min}}</th>
|
||||||
|
<th>{{total_max}}</th>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div id="chart"></div>
|
<div id="chart"></div>
|
||||||
<div id="tooltip"></div>
|
<div id="tooltip"></div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user