aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web
diff options
context:
space:
mode:
authoreugenijm <eugenijm@protonmail.com>2020-01-09 22:18:55 +0300
committereugenijm <eugenijm@protonmail.com>2020-02-24 21:46:37 +0300
commit7ad5c51f23102e89c491a2ef731e108873a09d71 (patch)
treeedfad3b8ea92b2037ef737a97acaa87d2ee00a34 /lib/pleroma/web
parentd240ce41b55a557366746fb7e313d3810bd8fe16 (diff)
downloadpleroma-7ad5c51f23102e89c491a2ef731e108873a09d71.tar.gz
Admin API: `GET /api/pleroma/admin/stats` to get status count by visibility scope
Diffstat (limited to 'lib/pleroma/web')
-rw-r--r--lib/pleroma/web/admin_api/admin_api_controller.ex10
-rw-r--r--lib/pleroma/web/router.ex1
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex
index 67222ebae..816b8938c 100644
--- a/lib/pleroma/web/admin_api/admin_api_controller.ex
+++ b/lib/pleroma/web/admin_api/admin_api_controller.ex
@@ -13,6 +13,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
alias Pleroma.ModerationLog
alias Pleroma.Plugs.OAuthScopesPlug
alias Pleroma.ReportNote
+ alias Pleroma.Stats
alias Pleroma.User
alias Pleroma.UserInviteToken
alias Pleroma.Web.ActivityPub.ActivityPub
@@ -98,7 +99,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
plug(
OAuthScopesPlug,
%{scopes: ["read"], admin: true}
- when action in [:config_show, :list_log]
+ when action in [:config_show, :list_log, :stats]
)
plug(
@@ -953,6 +954,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
conn |> json("")
end
+ def stats(conn, _) do
+ count = Stats.get_status_visibility_count()
+
+ conn
+ |> json(%{"status_visibility" => count})
+ end
+
def errors(conn, {:error, :not_found}) do
conn
|> put_status(:not_found)
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 9bfe86704..c2ffb025a 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -201,6 +201,7 @@ defmodule Pleroma.Web.Router do
get("/moderation_log", AdminAPIController, :list_log)
post("/reload_emoji", AdminAPIController, :reload_emoji)
+ get("/stats", AdminAPIController, :stats)
end
scope "/api/pleroma/emoji", Pleroma.Web.PleromaAPI do