stats update
This commit is contained in:
parent
14918f18a7
commit
4bf77ff3af
@ -14,19 +14,22 @@ class StatsView(BaseView):
|
|||||||
required_login = True
|
required_login = True
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
count = 20
|
count = 12
|
||||||
snapshots = list(Snapshot.objects.filter(project=self.request.user.selected_project).order_by('-created_at')[:count])
|
snapshots = list(Snapshot.objects.filter(project=self.request.user.selected_project).order_by('-created_at')[:count])
|
||||||
keys = set()
|
keys = set()
|
||||||
for snapshot in snapshots:
|
for snapshot in snapshots:
|
||||||
for key in snapshot.data:
|
for key in snapshot.data:
|
||||||
keys.add(key)
|
keys.add(key)
|
||||||
keys = list(keys)
|
keys = list(keys)
|
||||||
|
keys.sort()
|
||||||
rows = [[key] for key in keys]
|
rows = [[key] for key in keys]
|
||||||
|
times = []
|
||||||
for snapshot in snapshots:
|
for snapshot in snapshots:
|
||||||
|
times.append(snapshot.created_at)
|
||||||
for index, key in enumerate(keys):
|
for index, key in enumerate(keys):
|
||||||
rows[index].append(snapshot.data.get(key))
|
rows[index].append(snapshot.data.get(key))
|
||||||
self.context['keys'] = keys
|
|
||||||
self.context['data'] = rows
|
self.context['data'] = rows
|
||||||
|
self.context['times'] = times
|
||||||
self.context['err'] = 'err' in self.request.GET
|
self.context['err'] = 'err' in self.request.GET
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
|
@ -12,6 +12,12 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<th>Время</th>
|
||||||
|
{% for time in times %}
|
||||||
|
<th>{{ time.date.day }}-{{ time.date.month }}<br>{{ time.hour }}:{% if time.minute < 10 %}0{% endif %}{{ time.minute }}</th>
|
||||||
|
{% endfor %}
|
||||||
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for row in data %}
|
{% for row in data %}
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user