stats update
This commit is contained in:
parent
14918f18a7
commit
4bf77ff3af
@ -14,19 +14,22 @@ class StatsView(BaseView):
|
||||
required_login = True
|
||||
|
||||
def get(self):
|
||||
count = 20
|
||||
count = 12
|
||||
snapshots = list(Snapshot.objects.filter(project=self.request.user.selected_project).order_by('-created_at')[:count])
|
||||
keys = set()
|
||||
for snapshot in snapshots:
|
||||
for key in snapshot.data:
|
||||
keys.add(key)
|
||||
keys = list(keys)
|
||||
keys.sort()
|
||||
rows = [[key] for key in keys]
|
||||
times = []
|
||||
for snapshot in snapshots:
|
||||
times.append(snapshot.created_at)
|
||||
for index, key in enumerate(keys):
|
||||
rows[index].append(snapshot.data.get(key))
|
||||
self.context['keys'] = keys
|
||||
self.context['data'] = rows
|
||||
self.context['times'] = times
|
||||
self.context['err'] = 'err' in self.request.GET
|
||||
|
||||
def post(self):
|
||||
|
@ -12,6 +12,12 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
<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>
|
||||
{% for row in data %}
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user