mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
stats: Show info message in /stats page of newly created realms.
This provides a better user experience for folks joining a new Zulip realm and visiting this page.
This commit is contained in:
@@ -60,8 +60,12 @@ else:
|
|||||||
|
|
||||||
MAX_TIME_FOR_FULL_ANALYTICS_GENERATION = timedelta(days=1, minutes=30)
|
MAX_TIME_FOR_FULL_ANALYTICS_GENERATION = timedelta(days=1, minutes=30)
|
||||||
|
|
||||||
|
def is_analytics_ready(realm: Realm) -> bool:
|
||||||
|
return (timezone_now() - realm.date_created) > MAX_TIME_FOR_FULL_ANALYTICS_GENERATION
|
||||||
|
|
||||||
def render_stats(request: HttpRequest, data_url_suffix: str, target_name: str,
|
def render_stats(request: HttpRequest, data_url_suffix: str, target_name: str,
|
||||||
for_installation: bool=False, remote: bool=False) -> HttpRequest:
|
for_installation: bool=False, remote: bool=False,
|
||||||
|
analytics_ready: bool=True) -> HttpRequest:
|
||||||
page_params = dict(
|
page_params = dict(
|
||||||
data_url_suffix=data_url_suffix,
|
data_url_suffix=data_url_suffix,
|
||||||
for_installation=for_installation,
|
for_installation=for_installation,
|
||||||
@@ -71,7 +75,8 @@ def render_stats(request: HttpRequest, data_url_suffix: str, target_name: str,
|
|||||||
return render(request,
|
return render(request,
|
||||||
'analytics/stats.html',
|
'analytics/stats.html',
|
||||||
context=dict(target_name=target_name,
|
context=dict(target_name=target_name,
|
||||||
page_params=page_params))
|
page_params=page_params,
|
||||||
|
analytics_ready=analytics_ready))
|
||||||
|
|
||||||
@zulip_login_required
|
@zulip_login_required
|
||||||
def stats(request: HttpRequest) -> HttpResponse:
|
def stats(request: HttpRequest) -> HttpResponse:
|
||||||
@@ -80,7 +85,8 @@ def stats(request: HttpRequest) -> HttpResponse:
|
|||||||
# TODO: Make @zulip_login_required pass the UserProfile so we
|
# TODO: Make @zulip_login_required pass the UserProfile so we
|
||||||
# can use @require_member_or_admin
|
# can use @require_member_or_admin
|
||||||
raise JsonableError(_("Not allowed for guest users"))
|
raise JsonableError(_("Not allowed for guest users"))
|
||||||
return render_stats(request, '', realm.name or realm.string_id)
|
return render_stats(request, '', realm.name or realm.string_id,
|
||||||
|
analytics_ready=is_analytics_ready(realm))
|
||||||
|
|
||||||
@require_server_admin
|
@require_server_admin
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
@@ -90,7 +96,8 @@ def stats_for_realm(request: HttpRequest, realm_str: str) -> HttpResponse:
|
|||||||
except Realm.DoesNotExist:
|
except Realm.DoesNotExist:
|
||||||
return HttpResponseNotFound("Realm %s does not exist" % (realm_str,))
|
return HttpResponseNotFound("Realm %s does not exist" % (realm_str,))
|
||||||
|
|
||||||
return render_stats(request, '/realm/%s' % (realm_str,), realm.name or realm.string_id)
|
return render_stats(request, '/realm/%s' % (realm_str,), realm.name or realm.string_id,
|
||||||
|
analytics_ready=is_analytics_ready(realm))
|
||||||
|
|
||||||
@require_server_admin
|
@require_server_admin
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ p {
|
|||||||
width: 790px; /* chart = 750px + 20px padding */
|
width: 790px; /* chart = 750px + 20px padding */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.stats-page .alert {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.chart-container {
|
.chart-container {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
|
|||||||
@@ -2,9 +2,14 @@
|
|||||||
{% set entrypoint = "stats" %}
|
{% set entrypoint = "stats" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="app portico-page">
|
<div class="app portico-page stats-page">
|
||||||
|
|
||||||
<div class="page-content">
|
<div class="page-content">
|
||||||
|
{% if not analytics_ready %}
|
||||||
|
<div class="alert alert-info">
|
||||||
|
{{ _("Analytics are fully available 24 hours after organization creation.") }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div id="id_stats_errors" class="alert alert-error"></div>
|
<div id="id_stats_errors" class="alert alert-error"></div>
|
||||||
<div class="center-charts">
|
<div class="center-charts">
|
||||||
<h1 class="analytics-page-header">{% trans %}Zulip analytics for {{ target_name }}{% endtrans %}</h1>
|
<h1 class="analytics-page-header">{% trans %}Zulip analytics for {{ target_name }}{% endtrans %}</h1>
|
||||||
|
|||||||
Reference in New Issue
Block a user