X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fmix%2Ftasks%2Fpleroma%2Frefresh_counter_cache.ex;h=efcbaa3b1e9fc9962ae2a2a770059db4358ee4bd;hb=e1a1c8e7de5e10fa64d168dc5d35a80b96767395;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..efcbaa3b1 100644 --- a/lib/mix/tasks/pleroma/refresh_counter_cache.ex +++ b/lib/mix/tasks/pleroma/refresh_counter_cache.ex @@ -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(