aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2018-01-15 08:04:54 +0000
committerlambda <pleromagit@rogerbraun.net>2018-01-15 08:04:54 +0000
commit5a6f54b336c8cca7f6514bb9ce7db5b6c97f296f (patch)
tree54c66b8ed5693c168a30902b6ea463a426399426 /lib/pleroma/web
parentd49109ca17f980e118cd5ab97bc1139e3bd14402 (diff)
parent6e1cb86166d82a4ac4e5fb2ecf8955b18a7ab466 (diff)
downloadpleroma-5a6f54b336c8cca7f6514bb9ce7db5b6c97f296f.tar.gz
Merge branch 'stats-daemon' into 'develop'
Add a stats agent for storing data from expensive queries. See merge request pleroma/pleroma!45
Diffstat (limited to 'lib/pleroma/web')
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex13
-rw-r--r--lib/pleroma/web/router.ex1
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index ffa6f42c8..0615ac11a 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -1,6 +1,6 @@
defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
use Pleroma.Web, :controller
- alias Pleroma.{Repo, Activity, User, Notification}
+ alias Pleroma.{Repo, Activity, User, Notification, Stats}
alias Pleroma.Web
alias Pleroma.Web.MastodonAPI.{StatusView, AccountView, MastodonView}
alias Pleroma.Web.ActivityPub.ActivityPub
@@ -93,7 +93,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
@instance Application.get_env(:pleroma, :instance)
def masto_instance(conn, _params) do
- user_count = Repo.aggregate(User.local_user_query, :count, :id)
response = %{
uri: Web.base_url,
title: Keyword.get(@instance, :name),
@@ -103,17 +102,17 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
urls: %{
streaming_api: String.replace(Web.base_url, ["http","https"], "wss")
},
- stats: %{
- status_count: 2,
- user_count: user_count,
- domain_count: 3
- },
+ stats: Stats.get_stats,
max_toot_chars: Keyword.get(@instance, :limit)
}
json(conn, response)
end
+ def peers(conn, _params) do
+ json(conn, Stats.get_peers)
+ end
+
defp mastodonized_emoji do
Pleroma.Formatter.get_custom_emoji()
|> Enum.map(fn {shortcode, relative_url} ->
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 8e6681e68..09104fc86 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -106,6 +106,7 @@ defmodule Pleroma.Web.Router do
scope "/api/v1", Pleroma.Web.MastodonAPI do
pipe_through :api
get "/instance", MastodonAPIController, :masto_instance
+ get "/instance/peers", MastodonAPIController, :peers
post "/apps", MastodonAPIController, :create_app
get "/custom_emojis", MastodonAPIController, :custom_emojis