X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fmix%2Ftasks%2Fpleroma%2Frefresh_counter_cache.ex;h=66eed86570d7e0a0ea1f6c38a8d1fbf34710934d;hb=75b94a2f352ea255b0785d0f3ba2c849c8355e04;hp=280201befcfd0ad0fbeabe6bac4aa51afaeeb8ba;hpb=942093683a1e6b3f3d3692268b2af8390da6d325;p=akkoma
diff --git a/lib/mix/tasks/pleroma/refresh_counter_cache.ex b/lib/mix/tasks/pleroma/refresh_counter_cache.ex
index 280201bef..66eed8657 100644
--- a/lib/mix/tasks/pleroma/refresh_counter_cache.ex
+++ b/lib/mix/tasks/pleroma/refresh_counter_cache.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.RefreshCounterCache do
@@ -17,14 +17,21 @@ defmodule Mix.Tasks.Pleroma.RefreshCounterCache do
def run([]) do
Mix.Pleroma.start_pleroma()
- Activity
- |> distinct([a], true)
- |> select([a], fragment("split_part(?, '/', 3)", a.actor))
- |> Repo.all()
- |> Enum.each(fn instance ->
+ instances =
+ Activity
+ |> distinct([a], true)
+ |> select([a], fragment("split_part(?, '/', 3)", a.actor))
+ |> Repo.all()
+
+ instances
+ |> Enum.with_index(1)
+ |> Enum.each(fn {instance, i} ->
counters = instance_counters(instance)
CounterCache.set(instance, counters)
- Mix.Pleroma.shell_info("Setting #{instance} counters: #{inspect(counters)}")
+
+ Mix.Pleroma.shell_info(
+ "[#{i}/#{length(instances)}] Setting #{instance} counters: #{inspect(counters)}"
+ )
end)
Mix.Pleroma.shell_info("Done")
@@ -35,7 +42,7 @@ defmodule Mix.Tasks.Pleroma.RefreshCounterCache do
Activity
|> where([a], fragment("(? ->> 'type'::text) = 'Create'", a.data))
- |> where([a], like(a.actor, ^"%#{instance}%"))
+ |> where([a], fragment("split_part(?, '/', 3) = ?", a.actor, ^instance))
|> select(
[a],
{fragment(