2021-07-26 17:32:10 +02:00
|
|
|
from typing import List, Union
|
|
|
|
|
2020-04-30 17:30:41 +02:00
|
|
|
from django.conf.urls import include
|
|
|
|
from django.urls import path
|
2021-07-26 17:32:10 +02:00
|
|
|
from django.urls.resolvers import URLPattern, URLResolver
|
2016-12-20 02:30:08 +01:00
|
|
|
|
2021-06-18 00:12:55 +02:00
|
|
|
from analytics.views.installation_activity import get_installation_activity
|
2021-06-18 00:07:45 +02:00
|
|
|
from analytics.views.realm_activity import get_realm_activity
|
2021-06-17 23:25:14 +02:00
|
|
|
from analytics.views.stats import (
|
2020-09-22 05:31:38 +02:00
|
|
|
get_chart_data,
|
|
|
|
get_chart_data_for_installation,
|
|
|
|
get_chart_data_for_realm,
|
|
|
|
get_chart_data_for_remote_installation,
|
|
|
|
get_chart_data_for_remote_realm,
|
|
|
|
stats,
|
|
|
|
stats_for_installation,
|
|
|
|
stats_for_realm,
|
|
|
|
stats_for_remote_installation,
|
|
|
|
stats_for_remote_realm,
|
|
|
|
)
|
2021-06-17 23:37:52 +02:00
|
|
|
from analytics.views.support import support
|
2021-06-18 00:06:02 +02:00
|
|
|
from analytics.views.user_activity import get_user_activity
|
2020-09-22 06:04:45 +02:00
|
|
|
from zerver.lib.rest import rest_path
|
2013-11-05 19:30:18 +01:00
|
|
|
|
2021-07-26 17:32:10 +02:00
|
|
|
i18n_urlpatterns: List[Union[URLPattern, URLResolver]] = [
|
2017-02-02 22:14:10 +01:00
|
|
|
# Server admin (user_profile.is_staff) visible stats pages
|
2021-06-18 00:12:55 +02:00
|
|
|
path("activity", get_installation_activity),
|
2021-02-12 08:20:45 +01:00
|
|
|
path("activity/support", support, name="support"),
|
|
|
|
path("realm_activity/<realm_str>/", get_realm_activity),
|
2021-10-13 21:16:34 +02:00
|
|
|
path("user_activity/<user_profile_id>/", get_user_activity),
|
2021-02-12 08:20:45 +01:00
|
|
|
path("stats/realm/<realm_str>/", stats_for_realm),
|
|
|
|
path("stats/installation", stats_for_installation),
|
|
|
|
path("stats/remote/<int:remote_server_id>/installation", stats_for_remote_installation),
|
2021-02-12 08:19:30 +01:00
|
|
|
path(
|
2021-02-12 08:20:45 +01:00
|
|
|
"stats/remote/<int:remote_server_id>/realm/<int:remote_realm_id>/", stats_for_remote_realm
|
2021-02-12 08:19:30 +01:00
|
|
|
),
|
2016-12-20 02:30:08 +01:00
|
|
|
# User-visible stats page
|
2021-02-12 08:20:45 +01:00
|
|
|
path("stats", stats, name="stats"),
|
2016-12-20 02:30:08 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
# These endpoints are a part of the API (V1), which uses:
|
|
|
|
# * REST verbs
|
|
|
|
# * Basic auth (username:password is email:apiKey)
|
|
|
|
# * Takes and returns json-formatted data
|
|
|
|
#
|
|
|
|
# See rest_dispatch in zerver.lib.rest for an explanation of auth methods used
|
|
|
|
#
|
|
|
|
# All of these paths are accessed by either a /json or /api prefix
|
|
|
|
v1_api_and_json_patterns = [
|
|
|
|
# get data for the graphs at /stats
|
2021-02-12 08:20:45 +01:00
|
|
|
rest_path("analytics/chart_data", GET=get_chart_data),
|
|
|
|
rest_path("analytics/chart_data/realm/<realm_str>", GET=get_chart_data_for_realm),
|
|
|
|
rest_path("analytics/chart_data/installation", GET=get_chart_data_for_installation),
|
2021-02-12 08:19:30 +01:00
|
|
|
rest_path(
|
2021-02-12 08:20:45 +01:00
|
|
|
"analytics/chart_data/remote/<int:remote_server_id>/installation",
|
2021-02-12 08:19:30 +01:00
|
|
|
GET=get_chart_data_for_remote_installation,
|
|
|
|
),
|
|
|
|
rest_path(
|
2021-02-12 08:20:45 +01:00
|
|
|
"analytics/chart_data/remote/<int:remote_server_id>/realm/<int:remote_realm_id>",
|
2021-02-12 08:19:30 +01:00
|
|
|
GET=get_chart_data_for_remote_realm,
|
|
|
|
),
|
2016-12-20 02:30:08 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
i18n_urlpatterns += [
|
2021-02-12 08:20:45 +01:00
|
|
|
path("api/v1/", include(v1_api_and_json_patterns)),
|
|
|
|
path("json/", include(v1_api_and_json_patterns)),
|
2016-05-19 17:33:30 +02:00
|
|
|
]
|
2013-11-05 19:30:18 +01:00
|
|
|
|
2016-10-27 12:38:16 +02:00
|
|
|
urlpatterns = i18n_urlpatterns
|