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.views import generic
|
||||
|
||||
from .models import Server, PopulationHistory
|
||||
from .models import Server, PlayerHistory
|
||||
|
||||
class ServerListView(generic.ListView):
|
||||
model = Server
|
||||
@ -12,7 +13,13 @@ class ServerDetailView(generic.DetailView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ServerDetailView, self).get_context_data(**kwargs)
|
||||
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
|
||||
|
||||
|
||||
@ -18,12 +18,10 @@
|
||||
{% endif %}
|
||||
|
||||
<h2>Server History</h2>
|
||||
{% with population|first as status %}
|
||||
<p>Last updated <span title="{{status.timestamp|date:'r'}} GMT">
|
||||
{{status.timestamp|timesince}}
|
||||
</span>ago.</p>
|
||||
<p>Online players: {{status.players}}</p>
|
||||
{% endwith %}
|
||||
<p>Last updated <span title="{{last_updated|date:'r'}} GMT">
|
||||
{{last_updated|timesince}}
|
||||
</span>ago.</p>
|
||||
<p>Online players: {{online_players}}</p>
|
||||
|
||||
<div id="chart"></div>
|
||||
<div id="tooltip"></div>
|
||||
@ -34,8 +32,9 @@
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var series = [
|
||||
{% for tmp in population %}
|
||||
[{{tmp.timestamp|date:'U'}} * 1000, {{tmp.players}}],
|
||||
{% for timestamp, players in player_history %}
|
||||
{# convert timestamp to ms, because javascript... #}
|
||||
[{{timestamp|date:'U'}} * 1000, {{players}}],
|
||||
{% endfor %}
|
||||
];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user