From 4bf77ff3af240f28c83a002499d33742ccffb683 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 3 Oct 2023 20:43:56 +0300 Subject: [PATCH] stats update --- stats/views.py | 7 +++++-- templates/stats.html | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/stats/views.py b/stats/views.py index 4d33fc4..0fa04d0 100644 --- a/stats/views.py +++ b/stats/views.py @@ -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): diff --git a/templates/stats.html b/templates/stats.html index 3cec4de..88834f3 100644 --- a/templates/stats.html +++ b/templates/stats.html @@ -12,6 +12,12 @@ {% endif %} + + + {% for time in times %} + + {% endfor %} + {% for row in data %}
Время{{ time.date.day }}-{{ time.date.month }}
{{ time.hour }}:{% if time.minute < 10 %}0{% endif %}{{ time.minute }}