Fix latest group not refreshing in admin section

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-04-22 12:02:14 +02:00
parent 3ce8c142b8
commit e4a22bdb83
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
2 changed files with 10 additions and 7 deletions

View File

@ -213,12 +213,6 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
_ -> nil _ -> nil
end end
last_group_created =
case Actors.list_actors(:Group) do
%Page{elements: [group | _]} -> group
_ -> nil
end
{:ok, {:ok,
%{ %{
number_of_users: Statistics.get_cached_value(:local_users), number_of_users: Statistics.get_cached_value(:local_users),
@ -231,7 +225,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
number_of_followers: Statistics.get_cached_value(:instance_followers), number_of_followers: Statistics.get_cached_value(:instance_followers),
number_of_followings: Statistics.get_cached_value(:instance_followings), number_of_followings: Statistics.get_cached_value(:instance_followings),
last_public_event_published: last_public_event_published, last_public_event_published: last_public_event_published,
last_group_created: last_group_created last_group_created: Actors.last_group_created()
}} }}
end end

View File

@ -444,6 +444,15 @@ defmodule Mobilizon.Actors do
|> Repo.preload(:organized_events) |> Repo.preload(:organized_events)
end end
@spec last_group_created :: Actor.t() | nil
def last_group_created do
Actor
|> where(type: :Group, suspended: false)
|> order_by(desc: :inserted_at)
|> limit(1)
|> Repo.one()
end
@doc """ @doc """
Builds a page struct for actors by their name or displayed name. Builds a page struct for actors by their name or displayed name.
""" """