mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 15:58:25 -04:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user