From 20b2c11830f35752554dda7198541322f6017cf1 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Thu, 30 Nov 2017 21:28:56 -0800 Subject: [PATCH] activity: Show the time the data is from. I've wanted this when looking at a tab from the day before. Also provides the date and time in UTC, which is handy for interpreting some of the data. Pretty sure this is not the world's cleanest way to do this in the front-end code. It'll do for now. --- analytics/views.py | 7 +++++-- templates/analytics/realm_summary_table.html | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/analytics/views.py b/analytics/views.py index 9f305dfc79..937956a84d 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -287,6 +287,8 @@ def get_realm_day_counts() -> Dict[str, Dict[str, str]]: return result def realm_summary_table(realm_minutes: Dict[str, float]) -> str: + now = timezone_now() + query = ''' SELECT realm.string_id, @@ -397,7 +399,7 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str: for row in rows: row['date_created_day'] = row['date_created'].strftime('%Y-%m-%d') - row['age_days'] = int((timezone_now() - row['date_created']).total_seconds() + row['age_days'] = int((now - row['date_created']).total_seconds() / 86400) row['is_new'] = row['age_days'] < 12 * 7 @@ -455,7 +457,8 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str: content = loader.render_to_string( 'analytics/realm_summary_table.html', - dict(rows=rows, num_active_sites=num_active_sites) + dict(rows=rows, num_active_sites=num_active_sites, + now=now.strftime('%Y-%m-%dT%H:%M:%SZ')) ) return content diff --git a/templates/analytics/realm_summary_table.html b/templates/analytics/realm_summary_table.html index c638e84ad3..28a7323772 100644 --- a/templates/analytics/realm_summary_table.html +++ b/templates/analytics/realm_summary_table.html @@ -1,5 +1,13 @@

{{ num_active_sites }} active sites

+

+

+ +