mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Limit months shown to current and past
Matches what we do on the usage page. No need to see months in the future because there’s no way you’ll have sent any messages in those months, unless you’re Marty McFly.
This commit is contained in:
@@ -215,12 +215,17 @@ def format_monthly_stats_to_list(historical_stats):
|
||||
return sorted((
|
||||
dict(
|
||||
date=key,
|
||||
name=datetime(int(key[0:4]), int(key[5:7]), 1).strftime('%B'),
|
||||
future=YYYY_MM_to_datetime(key) > datetime.utcnow(),
|
||||
name=YYYY_MM_to_datetime(key).strftime('%B'),
|
||||
**aggregate_status_types(value)
|
||||
) for key, value in historical_stats.items()
|
||||
), key=lambda x: x['date'])
|
||||
|
||||
|
||||
def YYYY_MM_to_datetime(string):
|
||||
return datetime(int(string[0:4]), int(string[5:7]), 1)
|
||||
|
||||
|
||||
def aggregate_status_types(counts_dict):
|
||||
return get_dashboard_totals({
|
||||
'{}_counts'.format(message_type): {
|
||||
|
||||
Reference in New Issue
Block a user