fix(stats): leave our own host out of the peers

Favicon lookups for local accounts can add our own host to instances.
Also skip userinfo and IPv6 literals in the backfill migration.
This commit is contained in:
Lain Soykaf 2026-10-27 20:53:56 +04:00
commit 958166589e
No known key found for this signature in database
5 changed files with 15 additions and 4 deletions

View file

@ -67,7 +67,10 @@ defmodule Pleroma.Stats do
def calculate_stat_data do
# Hosts are unique in instances, and remote users add theirs. Scanning
# all remote users for their domains was one of the costliest queries.
peers = Repo.all(from(i in Instance, select: i.host))
# Favicon lookups for local accounts can add our own host, so skip it.
peers =
from(i in Instance, where: i.host != ^local_host(), select: i.host)
|> Repo.all()
domain_count = Enum.count(peers)
@ -93,6 +96,9 @@ defmodule Pleroma.Stats do
}
end
# Read from the config: this also runs before the endpoint has started.
defp local_host, do: Pleroma.Config.get([Pleroma.Web.Endpoint, :url, :host])
@spec get_status_visibility_count(String.t() | nil) :: map()
def get_status_visibility_count(instance \\ nil) do
if is_nil(instance) do