Replace map |> join with map_join
This commit is contained in:
parent
90ed27939b
commit
aba4e6ea60
15 changed files with 20 additions and 36 deletions
|
@ -224,8 +224,7 @@ defp hell_thread_mentions(users) do
|
||||||
|> Enum.reduce([users[:user]], fn group, acc ->
|
|> Enum.reduce([users[:user]], fn group, acc ->
|
||||||
acc ++ Enum.take(users[group], 5)
|
acc ++ Enum.take(users[group], 5)
|
||||||
end)
|
end)
|
||||||
|> Enum.map(&"@#{&1.nickname}")
|
|> Enum.map_join(", ", &"@#{&1.nickname}")
|
||||||
|> Enum.join(", ")
|
|
||||||
|
|
||||||
Cachex.put(:user_cache, "hell_thread_mentions", cached)
|
Cachex.put(:user_cache, "hell_thread_mentions", cached)
|
||||||
cached
|
cached
|
||||||
|
|
|
@ -303,7 +303,7 @@ def run(["gen" | rest]) do
|
||||||
else
|
else
|
||||||
shell_error(
|
shell_error(
|
||||||
"The task would have overwritten the following files:\n" <>
|
"The task would have overwritten the following files:\n" <>
|
||||||
(Enum.map(will_overwrite, &"- #{&1}\n") |> Enum.join("")) <>
|
Enum.map_join(will_overwrite, "", &"- #{&1}\n") <>
|
||||||
"Rerun with `--force` to overwrite them."
|
"Rerun with `--force` to overwrite them."
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,7 @@ def report(to, reporter, account, statuses, comment) do
|
||||||
if is_list(statuses) && length(statuses) > 0 do
|
if is_list(statuses) && length(statuses) > 0 do
|
||||||
statuses_list_html =
|
statuses_list_html =
|
||||||
statuses
|
statuses
|
||||||
|> Enum.map(fn
|
|> Enum.map_join("\n", fn
|
||||||
%{id: id} ->
|
%{id: id} ->
|
||||||
status_url = Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, id)
|
status_url = Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, id)
|
||||||
"<li><a href=\"#{status_url}\">#{status_url}</li>"
|
"<li><a href=\"#{status_url}\">#{status_url}</li>"
|
||||||
|
@ -54,7 +54,6 @@ def report(to, reporter, account, statuses, comment) do
|
||||||
id when is_binary(id) ->
|
id when is_binary(id) ->
|
||||||
"<li><a href=\"#{id}\">#{id}</li>"
|
"<li><a href=\"#{id}\">#{id}</li>"
|
||||||
end)
|
end)
|
||||||
|> Enum.join("\n")
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
<p> Statuses:
|
<p> Statuses:
|
||||||
|
|
|
@ -134,10 +134,9 @@ defp update_emojis(emojis) do
|
||||||
|> hd()
|
|> hd()
|
||||||
|> String.trim()
|
|> String.trim()
|
||||||
|> String.split()
|
|> String.split()
|
||||||
|> Enum.map(fn codepoint ->
|
|> Enum.map_join(fn codepoint ->
|
||||||
<<String.to_integer(codepoint, 16)::utf8>>
|
<<String.to_integer(codepoint, 16)::utf8>>
|
||||||
end)
|
end)
|
||||||
|> Enum.join()
|
|
||||||
end)
|
end)
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
|
|
||||||
|
|
|
@ -207,8 +207,7 @@ def compose_regex(%User{} = user, format) do
|
||||||
def compose_regex([_ | _] = filters, format) do
|
def compose_regex([_ | _] = filters, format) do
|
||||||
phrases =
|
phrases =
|
||||||
filters
|
filters
|
||||||
|> Enum.map(& &1.phrase)
|
|> Enum.map_join("|", & &1.phrase)
|
||||||
|> Enum.join("|")
|
|
||||||
|
|
||||||
case format do
|
case format do
|
||||||
:postgres ->
|
:postgres ->
|
||||||
|
|
|
@ -556,14 +556,12 @@ def get_log_entry_message(%ModerationLog{
|
||||||
|
|
||||||
defp nicknames_to_string(nicknames) do
|
defp nicknames_to_string(nicknames) do
|
||||||
nicknames
|
nicknames
|
||||||
|> Enum.map(&"@#{&1}")
|
|> Enum.map_join(", ", &"@#{&1}")
|
||||||
|> Enum.join(", ")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp users_to_nicknames_string(users) do
|
defp users_to_nicknames_string(users) do
|
||||||
users
|
users
|
||||||
|> Enum.map(&"@#{&1["nickname"]}")
|
|> Enum.map_join(", ", &"@#{&1["nickname"]}")
|
||||||
|> Enum.join(", ")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp subject_actor_nickname(%ModerationLog{data: data}, prefix_msg, postfix_msg \\ "") do
|
defp subject_actor_nickname(%ModerationLog{data: data}, prefix_msg, postfix_msg \\ "") do
|
||||||
|
|
|
@ -134,8 +134,7 @@ defp to_tsquery(query_string) do
|
||||||
|> String.replace(~r/[!-\/|@|[-`|{-~|:-?]+/, " ")
|
|> String.replace(~r/[!-\/|@|[-`|{-~|:-?]+/, " ")
|
||||||
|> String.trim()
|
|> String.trim()
|
||||||
|> String.split()
|
|> String.split()
|
||||||
|> Enum.map(&(&1 <> ":*"))
|
|> Enum.map_join(" | ", &(&1 <> ":*"))
|
||||||
|> Enum.join(" | ")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Considers nickname match, localized nickname match, name match; preferences nickname match
|
# Considers nickname match, localized nickname match, name match; preferences nickname match
|
||||||
|
|
|
@ -30,7 +30,7 @@ def call(conn, errors) do
|
||||||
conn
|
conn
|
||||||
|> put_status(:bad_request)
|
|> put_status(:bad_request)
|
||||||
|> json(%{
|
|> json(%{
|
||||||
error: errors |> Enum.map(&message/1) |> Enum.join(" "),
|
error: errors |> Enum.map_join(" ", &message/1),
|
||||||
errors: errors |> Enum.map(&render_error/1)
|
errors: errors |> Enum.map(&render_error/1)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
@ -167,8 +167,7 @@ defp preprocess_uri_query(query) do
|
||||||
|
|
||||||
defp joined_tag(tags) do
|
defp joined_tag(tags) do
|
||||||
tags
|
tags
|
||||||
|> Enum.map(fn tag -> String.capitalize(tag) end)
|
|> Enum.map_join(fn tag -> String.capitalize(tag) end)
|
||||||
|> Enum.join()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp with_fallback(f, fallback \\ []) do
|
defp with_fallback(f, fallback \\ []) do
|
||||||
|
|
|
@ -15,8 +15,7 @@ def build_static_tags(params) do
|
||||||
params
|
params
|
||||||
|> parser.build_tags()
|
|> parser.build_tags()
|
||||||
|> Enum.map(&to_tag/1)
|
|> Enum.map(&to_tag/1)
|
||||||
|> Enum.map(&HTML.safe_to_string/1)
|
|> Enum.map_join(&HTML.safe_to_string/1)
|
||||||
|> Enum.join()
|
|
||||||
|
|
||||||
acc <> rendered_html
|
acc <> rendered_html
|
||||||
end)
|
end)
|
||||||
|
@ -35,8 +34,7 @@ def build_tags(params) do
|
||||||
params
|
params
|
||||||
|> parser.build_tags()
|
|> parser.build_tags()
|
||||||
|> Enum.map(&to_tag/1)
|
|> Enum.map(&to_tag/1)
|
||||||
|> Enum.map(&HTML.safe_to_string/1)
|
|> Enum.map_join(&HTML.safe_to_string/1)
|
||||||
|> Enum.join()
|
|
||||||
|
|
||||||
acc <> rendered_html
|
acc <> rendered_html
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -244,8 +244,7 @@ defp attach_selected_params(input, %{conn_params: conn_params, opts: plug_opts})
|
||||||
plug_opts
|
plug_opts
|
||||||
|> Keyword.get(:params, [])
|
|> Keyword.get(:params, [])
|
||||||
|> Enum.sort()
|
|> Enum.sort()
|
||||||
|> Enum.map(&Map.get(conn_params, &1, ""))
|
|> Enum.map_join(":", &Map.get(conn_params, &1, ""))
|
||||||
|> Enum.join(":")
|
|
||||||
|
|
||||||
[input, params_string]
|
[input, params_string]
|
||||||
|> Enum.join(":")
|
|> Enum.join(":")
|
||||||
|
|
|
@ -94,8 +94,7 @@ test "logging user tagged by admin", %{admin: admin, subject1: subject1, subject
|
||||||
|
|
||||||
users =
|
users =
|
||||||
[subject1.nickname, subject2.nickname]
|
[subject1.nickname, subject2.nickname]
|
||||||
|> Enum.map(&"@#{&1}")
|
|> Enum.map_join(", ", &"@#{&1}")
|
||||||
|> Enum.join(", ")
|
|
||||||
|
|
||||||
tags = ["foo", "bar"] |> Enum.join(", ")
|
tags = ["foo", "bar"] |> Enum.join(", ")
|
||||||
|
|
||||||
|
@ -115,8 +114,7 @@ test "logging user untagged by admin", %{admin: admin, subject1: subject1, subje
|
||||||
|
|
||||||
users =
|
users =
|
||||||
[subject1.nickname, subject2.nickname]
|
[subject1.nickname, subject2.nickname]
|
||||||
|> Enum.map(&"@#{&1}")
|
|> Enum.map_join(", ", &"@#{&1}")
|
||||||
|> Enum.join(", ")
|
|
||||||
|
|
||||||
tags = ["foo", "bar"] |> Enum.join(", ")
|
tags = ["foo", "bar"] |> Enum.join(", ")
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,7 @@ test "it appends specified tags to users with specified nicknames", %{
|
||||||
|
|
||||||
users =
|
users =
|
||||||
[user1.nickname, user2.nickname]
|
[user1.nickname, user2.nickname]
|
||||||
|> Enum.map(&"@#{&1}")
|
|> Enum.map_join(", ", &"@#{&1}")
|
||||||
|> Enum.join(", ")
|
|
||||||
|
|
||||||
tags = ["foo", "bar"] |> Enum.join(", ")
|
tags = ["foo", "bar"] |> Enum.join(", ")
|
||||||
|
|
||||||
|
@ -168,8 +167,7 @@ test "it removes specified tags from users with specified nicknames", %{
|
||||||
|
|
||||||
users =
|
users =
|
||||||
[user1.nickname, user2.nickname]
|
[user1.nickname, user2.nickname]
|
||||||
|> Enum.map(&"@#{&1}")
|
|> Enum.map_join(", ", &"@#{&1}")
|
||||||
|> Enum.join(", ")
|
|
||||||
|
|
||||||
tags = ["x", "z"] |> Enum.join(", ")
|
tags = ["x", "z"] |> Enum.join(", ")
|
||||||
|
|
||||||
|
|
|
@ -247,8 +247,7 @@ test "Removes a conversation", %{user: user_one, conn: conn} do
|
||||||
defp create_direct_message(sender, recips) do
|
defp create_direct_message(sender, recips) do
|
||||||
hellos =
|
hellos =
|
||||||
recips
|
recips
|
||||||
|> Enum.map(fn s -> "@#{s.nickname}" end)
|
|> Enum.map_join(", ", fn s -> "@#{s.nickname}" end)
|
||||||
|> Enum.join(", ")
|
|
||||||
|
|
||||||
CommonAPI.post(sender, %{
|
CommonAPI.post(sender, %{
|
||||||
status: "Hi #{hellos}!",
|
status: "Hi #{hellos}!",
|
||||||
|
|
|
@ -630,8 +630,8 @@ test "update fields when invalid request", %{conn: conn} do
|
||||||
name_limit = Pleroma.Config.get([:instance, :account_field_name_length])
|
name_limit = Pleroma.Config.get([:instance, :account_field_name_length])
|
||||||
value_limit = Pleroma.Config.get([:instance, :account_field_value_length])
|
value_limit = Pleroma.Config.get([:instance, :account_field_value_length])
|
||||||
|
|
||||||
long_name = Enum.map(0..name_limit, fn _ -> "x" end) |> Enum.join()
|
long_name = Enum.map_join(0..name_limit, fn _ -> "x" end)
|
||||||
long_value = Enum.map(0..value_limit, fn _ -> "x" end) |> Enum.join()
|
long_value = Enum.map_join(0..value_limit, fn _ -> "x" end)
|
||||||
|
|
||||||
fields = [%{name: "foo", value: long_value}]
|
fields = [%{name: "foo", value: long_value}]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue