mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Let users filter by type of event
At the moment we have two types of event, ‘service’ events and ‘API key’ events. They are munged together which is useful initially, but could get noisy. This commit adds filters (copied from the choose template page) that let users narrow down the list to one of the two types of event. This might help users get a clearer picture of what’s going on.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from collections import defaultdict
|
||||
|
||||
from flask import render_template
|
||||
from flask import render_template, request
|
||||
|
||||
from app import current_service, format_date_numeric
|
||||
from app.main import main
|
||||
@@ -14,12 +14,16 @@ def history(service_id):
|
||||
return render_template(
|
||||
'views/temp-history.html',
|
||||
days=_chunk_events_by_day(
|
||||
_get_events(current_service.id)
|
||||
_get_events(current_service.id, request.args.get('selected'))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _get_events(service_id):
|
||||
def _get_events(service_id, selected):
|
||||
if selected == 'api':
|
||||
return APIKeyEvents(service_id)
|
||||
if selected == 'service':
|
||||
return ServiceEvents(service_id)
|
||||
return APIKeyEvents(service_id) + ServiceEvents(service_id)
|
||||
|
||||
|
||||
@@ -27,7 +31,7 @@ def _chunk_events_by_day(events):
|
||||
|
||||
days = defaultdict(list)
|
||||
|
||||
for event in reversed(events):
|
||||
for event in events:
|
||||
days[format_date_numeric(event.time)].append(event)
|
||||
|
||||
return sorted(days.items(), reverse=True)
|
||||
|
||||
Reference in New Issue
Block a user