From cdb05633a6dbc7633f55cd462bdee82e44942caf Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 4 Mar 2020 13:33:26 -0600 Subject: [PATCH 1/2] Generate instance stats on startup --- lib/pleroma/stats.ex | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/pleroma/stats.ex b/lib/pleroma/stats.ex index 33f50dda8..4446562ac 100644 --- a/lib/pleroma/stats.ex +++ b/lib/pleroma/stats.ex @@ -10,19 +10,10 @@ defmodule Pleroma.Stats do use GenServer - @init_state %{ - peers: [], - stats: %{ - domain_count: 0, - status_count: 0, - user_count: 0 - } - } - def start_link(_) do GenServer.start_link( __MODULE__, - @init_state, + nil, name: __MODULE__ ) end @@ -53,8 +44,8 @@ defmodule Pleroma.Stats do peers end - def init(args) do - {:ok, args} + def init(_args) do + {:ok, get_stat_data()} end def handle_call(:force_update, _from, _state) do From ec3dc462ff34693a8290f7c86b2dfac5e4db9b86 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 4 Mar 2020 13:41:04 -0600 Subject: [PATCH 2/2] Document the instance stats fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8f3794a3..4f7a9f44c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Logger: default log level changed from `warn` to `info`. - Config mix task `migrate_to_db` truncates `config` table before migrating the config file. - Default to `prepare: :unnamed` in the database configuration. +- Instance stats are now loaded on startup instead of being empty until next hourly job.
API Changes