Merge branch 'fix/stats-on-startup' into 'develop'

Generate instance stats on startup

Closes #1598

See merge request pleroma/pleroma!2271
This commit is contained in:
Haelwenn 2020-03-05 07:25:23 +00:00
commit 927079e2ff
2 changed files with 4 additions and 12 deletions

View file

@ -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`. - Logger: default log level changed from `warn` to `info`.
- Config mix task `migrate_to_db` truncates `config` table before migrating the config file. - Config mix task `migrate_to_db` truncates `config` table before migrating the config file.
- Default to `prepare: :unnamed` in the database configuration. - Default to `prepare: :unnamed` in the database configuration.
- Instance stats are now loaded on startup instead of being empty until next hourly job.
<details> <details>
<summary>API Changes</summary> <summary>API Changes</summary>

View file

@ -10,19 +10,10 @@ defmodule Pleroma.Stats do
use GenServer use GenServer
@init_state %{
peers: [],
stats: %{
domain_count: 0,
status_count: 0,
user_count: 0
}
}
def start_link(_) do def start_link(_) do
GenServer.start_link( GenServer.start_link(
__MODULE__, __MODULE__,
@init_state, nil,
name: __MODULE__ name: __MODULE__
) )
end end
@ -53,8 +44,8 @@ defmodule Pleroma.Stats do
peers peers
end end
def init(args) do def init(_args) do
{:ok, args} {:ok, get_stat_data()}
end end
def handle_call(:force_update, _from, _state) do def handle_call(:force_update, _from, _state) do