From c3f9e24c70722366a31c20eae24fdb81790df2f8 Mon Sep 17 00:00:00 2001 From: Dashie Date: Thu, 3 May 2018 15:31:39 +0200 Subject: [PATCH] Use a variable for stats to avoid double call --- lib/pleroma/web/nodeinfo/nodeinfo_controller.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index 83ad4f284..36a7802ed 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -22,6 +22,8 @@ def schemas(conn, _params) do # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json def nodeinfo(conn, %{"version" => "2.0"}) do + stats = Stats.get_stats() + response = %{ version: "2.0", software: %{ @@ -36,9 +38,9 @@ def nodeinfo(conn, %{"version" => "2.0"}) do openRegistrations: Keyword.get(@instance, :registrations_open), usage: %{ users: %{ - total: Stats.get_stats().user_count || 0 + total: stats.user_count || 0 }, - localPosts: Stats.get_stats().status_count || 0 + localPosts: stats.status_count || 0 }, metadata: %{ nodeName: Keyword.get(@instance, :name)