Fix refactoring opportunities
This commit is contained in:
committed by
Thomas Citharel
parent
4d4fdaaffe
commit
20dfce5c83
@@ -12,7 +12,7 @@ defmodule MobilizonWeb.Resolvers.Address do
|
||||
"""
|
||||
@spec search(map(), map(), map()) :: {:ok, list(Address.t())}
|
||||
def search(_parent, %{query: query, page: _page, limit: _limit}, %{context: %{ip: ip}}) do
|
||||
country = Geolix.lookup(ip) |> Map.get(:country, nil)
|
||||
country = ip |> Geolix.lookup() |> Map.get(:country, nil)
|
||||
|
||||
local_addresses = Task.async(fn -> Addresses.search_addresses(query, country: country) end)
|
||||
|
||||
@@ -40,7 +40,7 @@ defmodule MobilizonWeb.Resolvers.Address do
|
||||
"""
|
||||
@spec reverse_geocode(map(), map(), map()) :: {:ok, list(Address.t())}
|
||||
def reverse_geocode(_parent, %{longitude: longitude, latitude: latitude}, %{context: %{ip: ip}}) do
|
||||
country = Geolix.lookup(ip) |> Map.get(:country, nil)
|
||||
country = ip |> Geolix.lookup() |> Map.get(:country, nil)
|
||||
|
||||
local_addresses =
|
||||
Task.async(fn -> Addresses.reverse_geocode(longitude, latitude, country: country) end)
|
||||
|
||||
@@ -10,26 +10,25 @@ defmodule MobilizonWeb.Resolvers.Admin do
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Service.Statistics
|
||||
|
||||
def list_action_logs(_parent, %{page: page, limit: limit}, %{
|
||||
context: %{current_user: %User{role: role}}
|
||||
})
|
||||
def list_action_logs(
|
||||
_parent,
|
||||
%{page: page, limit: limit},
|
||||
%{context: %{current_user: %User{role: role}}}
|
||||
)
|
||||
when is_moderator(role) do
|
||||
with action_logs <- Mobilizon.Admin.list_action_logs(page, limit) do
|
||||
action_logs =
|
||||
Enum.map(action_logs, fn %ActionLog{
|
||||
target_type: target_type,
|
||||
action: action,
|
||||
actor: actor,
|
||||
id: id,
|
||||
inserted_at: inserted_at
|
||||
} = action_log ->
|
||||
action_logs
|
||||
|> Enum.map(fn %ActionLog{
|
||||
target_type: target_type,
|
||||
action: action,
|
||||
actor: actor,
|
||||
id: id,
|
||||
inserted_at: inserted_at
|
||||
} = action_log ->
|
||||
with data when is_map(data) <-
|
||||
transform_action_log(String.to_existing_atom(target_type), action, action_log) do
|
||||
Map.merge(data, %{
|
||||
actor: actor,
|
||||
id: id,
|
||||
inserted_at: inserted_at
|
||||
})
|
||||
Map.merge(data, %{actor: actor, id: id, inserted_at: inserted_at})
|
||||
end
|
||||
end)
|
||||
|> Enum.filter(& &1)
|
||||
|
||||
@@ -31,7 +31,8 @@ defmodule MobilizonWeb.Resolvers.Group do
|
||||
def list_groups(_parent, %{page: page, limit: limit}, _resolution) do
|
||||
{
|
||||
:ok,
|
||||
Actors.list_groups(page, limit)
|
||||
page
|
||||
|> Actors.list_groups(limit)
|
||||
|> Enum.map(fn actor -> Person.proxify_pictures(actor) end)
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user