@require_server_admin
def get_realm_activity(request: HttpRequest, realm_str: str) -> HttpResponse:
    data: List[Tuple[(str, str)]] = []
    all_user_records: Dict[(str, Any)] = {}
    try:
        admins = Realm.objects.get(string_id=realm_str).get_human_admin_users()
    except Realm.DoesNotExist:
        return HttpResponseNotFound(f'Realm {realm_str} does not exist')
    admin_emails = {admin.delivery_email for admin in admins}
    for (is_bot, page_title) in [(False, 'Humans'), (True, 'Bots')]:
        all_records = list(get_user_activity_records_for_realm(realm_str, is_bot))
        (user_records, content) = realm_user_summary_table(all_records, admin_emails)
        all_user_records.update(user_records)
        data += [(page_title, content)]
    page_title = 'Clients'
    content = realm_client_table(all_user_records)
    data += [(page_title, content)]
    page_title = 'History'
    content = sent_messages_report(realm_str)
    data += [(page_title, content)]
    title = realm_str
    return render(request, 'analytics/activity.html', context=dict(data=data, realm_link=None, title=title))
@require_server_admin
def get_realm_activity(request: HttpRequest, realm_str: str) -> HttpResponse:
    data: List[Tuple[(str, str)]] = []
    all_user_records: Dict[(str, Any)] = {}
    try:
        admins = Realm.objects.get(string_id=realm_str).get_human_admin_users()
    except Realm.DoesNotExist:
        return HttpResponseNotFound(f'Realm {realm_str} does not exist')
    admin_emails = {admin.delivery_email for admin in admins}
    for (is_bot, page_title) in [(False, 'Humans'), (True, 'Bots')]:
        all_records = list(get_user_activity_records_for_realm(realm_str, is_bot))
        (user_records, content) = realm_user_summary_table(all_records, admin_emails)
        all_user_records.update(user_records)
        data += [(page_title, content)]
    page_title = 'Clients'
    content = realm_client_table(all_user_records)
    data += [(page_title, content)]
    page_title = 'History'
    content = sent_messages_report(realm_str)
    data += [(page_title, content)]
    title = realm_str
    return render(request, 'analytics/activity.html', context=dict(data=data, realm_link=None, title=title))