mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
activity: Add a link to copy list of realm admins.
Tweaked by tabbott to do the database queries properly. This should help user to copy realm admin emails in a go. Fixes: #7885
This commit is contained in:
@@ -33,7 +33,7 @@ from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.timestamp import ceiling_to_day, \
|
||||
ceiling_to_hour, convert_to_UTC, timestamp_to_datetime
|
||||
from zerver.models import Client, Realm, \
|
||||
from zerver.models import Client, get_realm, Realm, \
|
||||
UserActivity, UserActivityInterval, UserProfile
|
||||
|
||||
@zulip_login_required
|
||||
@@ -397,11 +397,20 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str:
|
||||
rows = dictfetchall(cursor)
|
||||
cursor.close()
|
||||
|
||||
# Fetch all the realm administrator users
|
||||
realm_admins = defaultdict(list)
|
||||
for up in UserProfile.objects.select_related("realm").filter(
|
||||
is_realm_admin=True,
|
||||
is_active=True
|
||||
):
|
||||
realm_admins[up.realm.string_id].append(up.email)
|
||||
|
||||
for row in rows:
|
||||
row['date_created_day'] = row['date_created'].strftime('%Y-%m-%d')
|
||||
row['age_days'] = int((now - row['date_created']).total_seconds()
|
||||
/ 86400)
|
||||
row['is_new'] = row['age_days'] < 12 * 7
|
||||
row['realm_admin_email'] = ', '.join(realm_admins[row['string_id']])
|
||||
|
||||
# get messages sent per day
|
||||
counts = get_realm_day_counts()
|
||||
@@ -448,6 +457,7 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str:
|
||||
rows.append(dict(
|
||||
string_id='Total',
|
||||
date_created_day='',
|
||||
realm_admin_email='',
|
||||
dau_count=total_dau_count,
|
||||
user_profile_count=total_user_profile_count,
|
||||
bot_count=total_bot_count,
|
||||
|
||||
@@ -6,6 +6,17 @@
|
||||
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') + ')';
|
||||
$(document).ready(function() {
|
||||
$('a.envelope-link').click(function() {
|
||||
var temp = $(document.createElement('input'));
|
||||
$("body").append(temp);
|
||||
temp.val($(this).data("value")).select();
|
||||
document.execCommand("copy");
|
||||
temp.remove();
|
||||
$(this).fadeOut(250);
|
||||
$(this).fadeIn(1000);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<ul>
|
||||
@@ -13,6 +24,7 @@
|
||||
<li>sites are listed if ≥1 users active in last 2 weeks</li>
|
||||
<li><strong>user</strong> - registered user, not deactivated, not a bot</li>
|
||||
<li><strong>active (user)</strong> - sent a message, or advanced the pointer (reading messages doesn't count unless advances the pointer)</li>
|
||||
<li><strong><th><i class="fa fa-envelope"></i></th></strong> - copies realm admin emails to clipboard</li>
|
||||
<li><strong>DAU</strong> (Daily Active Users) - users active in last 24hr</li>
|
||||
<li><strong>WAU</strong> (Weekly Active Users) - users active in last 7 * 24hr</li>
|
||||
<li><strong>DAT</strong> (Daily Active Time) - total user-activity time in last 24hr</li>
|
||||
@@ -25,6 +37,7 @@
|
||||
<tr>
|
||||
<th>Realm</th>
|
||||
<th>Created (green if ≤12wk)</th>
|
||||
<th><i class="fa fa-envelope"></i></th>
|
||||
<th>DAU</th>
|
||||
<th>WAU</th>
|
||||
<th>Total users</th>
|
||||
@@ -50,6 +63,14 @@
|
||||
{{ row.date_created_day }}
|
||||
</td>
|
||||
|
||||
<td class="envelope">
|
||||
{% if not loop.last %}
|
||||
<a class="envelope-link" data-value="{{ row.realm_admin_email }}">
|
||||
<i class="fa fa-envelope"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="number">
|
||||
{{ row.dau_count }}
|
||||
</td>
|
||||
|
||||
@@ -818,7 +818,10 @@ PIPELINE = {
|
||||
# If you add a style here, please update stylesheets()
|
||||
# in frontend_tests/zjsunit/output.js as needed.
|
||||
'activity': {
|
||||
'source_filenames': ('styles/activity.css',),
|
||||
'source_filenames': (
|
||||
'styles/activity.css',
|
||||
'third/thirdparty-fonts.css',
|
||||
),
|
||||
'output_filename': 'min/activity.css'
|
||||
},
|
||||
'stats': {
|
||||
|
||||
Reference in New Issue
Block a user