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.
This commit is contained in:
Greg Price 2017-11-30 21:28:56 -08:00
parent bdea0960de
commit 20b2c11830
2 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -1,5 +1,13 @@
<h2 style="text-align: center;">{{ num_active_sites }} active sites</h2>
<p id="utctime" style="text-align: center;"></p>
<p id="localtime" style="text-align: center;"></p>
<script type="text/javascript">
var now = moment('{{ now }}');
$('#utctime')[0].innerHTML = moment.utc(now).format('YYYY-MM-DD HH:mm') + 'Z';
$('#localtime')[0].innerHTML = '(' + now.format('YYYY-MM-DD HH:mm ZZ') + ')';
</script>
<ul>
<li><strong>active (site)</strong> - has ≥5 DAUs</li>
<li>sites are listed if ≥1 users active in last 2 weeks</li>