mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-04-14 07:23:59 +02:00
Merge 752c24dd9b
into 78550a6322
This commit is contained in:
commit
ba820ddbac
3 changed files with 11 additions and 7 deletions
lib/philomena_web
|
@ -44,6 +44,6 @@ defmodule PhilomenaWeb.SearchController do
|
|||
defp search_function(true), do: &Search.search_records_with_hits/2
|
||||
defp search_function(_custom), do: &Search.search_records/2
|
||||
|
||||
defp custom_ordering?(%{params: %{"sf" => sf}}) when sf != "id", do: true
|
||||
defp custom_ordering?(%{params: %{"sf" => sf}}) when sf not in ~W(id first_seen_at), do: true
|
||||
defp custom_ordering?(_conn), do: false
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ defmodule PhilomenaWeb.ImageNavigator do
|
|||
}
|
||||
|
||||
def find_consecutive(conn, image, compiled_query, compiled_filter) do
|
||||
conn = update_in(conn.params, &Map.put_new(&1, "sf", "id"))
|
||||
conn = update_in(conn.params, &Map.put_new(&1, "sf", "first_seen_at"))
|
||||
|
||||
%{query: compiled_query, sorts: sorts} = ImageSorter.parse_sort(conn.params, compiled_query)
|
||||
|
||||
|
@ -22,7 +22,7 @@ defmodule PhilomenaWeb.ImageNavigator do
|
|||
conn.params["sort"]
|
||||
|> permit_list()
|
||||
|> Enum.flat_map(&permit_value/1)
|
||||
|> default_value(image.id)
|
||||
|> default_cursors(conn.params["sf"], image)
|
||||
|
||||
maybe_search_after(
|
||||
Image,
|
||||
|
@ -62,6 +62,13 @@ defmodule PhilomenaWeb.ImageNavigator do
|
|||
[]
|
||||
end
|
||||
|
||||
defp default_cursors([], "id", image), do: [image.id]
|
||||
|
||||
defp default_cursors([], "first_seen_at", image),
|
||||
do: [image.first_seen_at |> DateTime.to_unix(:millisecond), image.id]
|
||||
|
||||
defp default_cursors(list, _sf, _image), do: list
|
||||
|
||||
defp apply_direction({"galleries.position", sort_body}, rel) do
|
||||
sort_body = update_in(sort_body.order, fn direction -> @order_for_dir[rel][direction] end)
|
||||
|
||||
|
@ -78,9 +85,6 @@ defmodule PhilomenaWeb.ImageNavigator do
|
|||
defp permit_value(value) when is_binary(value) or is_number(value), do: [value]
|
||||
defp permit_value(_value), do: []
|
||||
|
||||
defp default_value([], term), do: [term]
|
||||
defp default_value(list, _term), do: list
|
||||
|
||||
defp hidden_filter(%{id: id}, param) when param != "1", do: %{term: %{hidden_by_user_ids: id}}
|
||||
defp hidden_filter(_user, _param), do: %{match_none: %{}}
|
||||
end
|
||||
|
|
|
@ -80,7 +80,7 @@ defmodule PhilomenaWeb.ImageSorter do
|
|||
end
|
||||
|
||||
defp parse_sf(_params, sd, query) do
|
||||
%{query: query, sorts: [%{"first_seen_at" => sd}]}
|
||||
%{query: query, sorts: [%{"first_seen_at" => sd}, %{"id" => sd}]}
|
||||
end
|
||||
|
||||
defp random_query(seed, sd, query) do
|
||||
|
|
Loading…
Add table
Reference in a new issue