Server_details.html gets stats from the redis storage now.
This commit is contained in:
parent
b57d89788f
commit
860c063f1d
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
|
|
||||||
from .models import Server, PopulationHistory
|
from .models import Server, PlayerHistory
|
||||||
|
|
||||||
class ServerListView(generic.ListView):
|
class ServerListView(generic.ListView):
|
||||||
model = Server
|
model = Server
|
||||||
@ -12,7 +13,13 @@ class ServerDetailView(generic.DetailView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ServerDetailView, self).get_context_data(**kwargs)
|
context = super(ServerDetailView, self).get_context_data(**kwargs)
|
||||||
server = context['server']
|
server = context['server']
|
||||||
# HACK: 24 hours for the last 7 days, might want to change this
|
|
||||||
context['population'] = PopulationHistory.objects.filter(server=server)[:7*24*4]
|
history = PlayerHistory()
|
||||||
|
points = history.get_points(server)
|
||||||
|
context['player_history'] = points
|
||||||
|
|
||||||
|
timestamp, players = points[0]
|
||||||
|
context['last_updated'] = timestamp
|
||||||
|
context['online_players'] = players
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
@ -18,12 +18,10 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2>Server History</h2>
|
<h2>Server History</h2>
|
||||||
{% with population|first as status %}
|
<p>Last updated <span title="{{last_updated|date:'r'}} GMT">
|
||||||
<p>Last updated <span title="{{status.timestamp|date:'r'}} GMT">
|
{{last_updated|timesince}}
|
||||||
{{status.timestamp|timesince}}
|
</span>ago.</p>
|
||||||
</span>ago.</p>
|
<p>Online players: {{online_players}}</p>
|
||||||
<p>Online players: {{status.players}}</p>
|
|
||||||
{% endwith %}
|
|
||||||
|
|
||||||
<div id="chart"></div>
|
<div id="chart"></div>
|
||||||
<div id="tooltip"></div>
|
<div id="tooltip"></div>
|
||||||
@ -34,8 +32,9 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
var series = [
|
var series = [
|
||||||
{% for tmp in population %}
|
{% for timestamp, players in player_history %}
|
||||||
[{{tmp.timestamp|date:'U'}} * 1000, {{tmp.players}}],
|
{# convert timestamp to ms, because javascript... #}
|
||||||
|
[{{timestamp|date:'U'}} * 1000, {{players}}],
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user