Chunk events by day

Scanning the page is difficult at the moment because it’s hard to tell
how far apart in time events are, and thereby determine which events
might be related.

Grouping the events by day quickly lets users narrow their focus to
a meaningful subset of the events.
This commit is contained in:
Chris Hill-Scott
2019-10-18 16:43:52 +01:00
parent 59b4d60c91
commit b2ebaf153a
7 changed files with 121 additions and 23 deletions

View File

@@ -1,5 +1,8 @@
from collections import defaultdict
from flask import render_template
from app import current_service, format_date_numeric
from app.main import main
from app.utils import user_has_permissions
@@ -7,4 +10,17 @@ from app.utils import user_has_permissions
@main.route("/services/<service_id>/history")
@user_has_permissions('manage_service')
def history(service_id):
return render_template('views/temp-history.html')
return render_template(
'views/temp-history.html',
days=_chunk_events_by_day(current_service.history)
)
def _chunk_events_by_day(events):
days = defaultdict(list)
for event in reversed(events):
days[format_date_numeric(event.time)].append(event)
return sorted(days.items(), reverse=True)