mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Further improve only_tag filtering
This commit is contained in:
parent
101aec001b
commit
ba87c1679e
1 changed files with 7 additions and 5 deletions
|
@ -31,7 +31,7 @@ defmodule PhilomenaWeb.Profile.TagChangeController do
|
||||||
# params.permit(:added, :only_tag) ...
|
# params.permit(:added, :only_tag) ...
|
||||||
pagination_params =
|
pagination_params =
|
||||||
[added: conn.params["added"], only_tag: conn.params["only_tag"]]
|
[added: conn.params["added"], only_tag: conn.params["only_tag"]]
|
||||||
|> Keyword.filter(fn {k, _v} -> Map.has_key?(conn.params, "#{k}") end)
|
|> Keyword.filter(fn {_k, v} -> not is_nil(v) and v != "" end)
|
||||||
|
|
||||||
render(conn, "index.html",
|
render(conn, "index.html",
|
||||||
title: "Tag Changes for User `#{user.name}'",
|
title: "Tag Changes for User `#{user.name}'",
|
||||||
|
@ -50,13 +50,15 @@ defmodule PhilomenaWeb.Profile.TagChangeController do
|
||||||
defp added_filter(query, _params),
|
defp added_filter(query, _params),
|
||||||
do: query
|
do: query
|
||||||
|
|
||||||
defp only_tag_join(query, %{"only_tag" => only_tag}) when only_tag != "",
|
defp only_tag_join(query, %{"only_tag" => only_tag})
|
||||||
|
when is_binary(only_tag) and only_tag != "",
|
||||||
do: join(query, :inner, [tc], t in Tag, on: tc.tag_id == t.id)
|
do: join(query, :inner, [tc], t in Tag, on: tc.tag_id == t.id)
|
||||||
|
|
||||||
defp only_tag_join(query, _params),
|
defp only_tag_join(query, _params),
|
||||||
do: query
|
do: query
|
||||||
|
|
||||||
defp only_tag_filter(query, %{"only_tag" => only_tag}) when only_tag != "",
|
defp only_tag_filter(query, %{"only_tag" => only_tag})
|
||||||
|
when is_binary(only_tag) and only_tag != "",
|
||||||
do: where(query, [_, _, t], t.name == ^only_tag)
|
do: where(query, [_, _, t], t.name == ^only_tag)
|
||||||
|
|
||||||
defp only_tag_filter(query, _params),
|
defp only_tag_filter(query, _params),
|
||||||
|
|
Loading…
Reference in a new issue