From 45e3d2801d8184b485f09821cefb9ba2049bcf83 Mon Sep 17 00:00:00 2001 From: Luna D Date: Thu, 19 Dec 2019 17:39:34 -0500 Subject: [PATCH] *D (only deleted, no merges) search opt --- docker-compose.yml | 2 +- lib/philomena/images/elasticsearch.ex | 2 ++ lib/philomena_web/image_loader.ex | 3 +++ .../templates/image/_deleted_toggle.html.slime | 6 ++++++ lib/philomena_web/templates/layout/_header.html.slime | 2 +- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0b3af0a5..12bc1ccc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,4 +53,4 @@ services: depends_on: - app ports: - - '8080:80' \ No newline at end of file + - '8080:80' diff --git a/lib/philomena/images/elasticsearch.ex b/lib/philomena/images/elasticsearch.ex index fdd58e46..d1b7a482 100644 --- a/lib/philomena/images/elasticsearch.ex +++ b/lib/philomena/images/elasticsearch.ex @@ -24,6 +24,7 @@ defmodule Philomena.Images.Elasticsearch do downvoter_ids: %{type: "keyword"}, downvoters: %{type: "keyword"}, downvotes: %{type: "integer"}, + duplicate_id: %{type: "integer"}, faves: %{type: "integer"}, favourited_by_user_ids: %{type: "keyword"}, favourited_by_users: %{type: "keyword"}, @@ -118,6 +119,7 @@ defmodule Philomena.Images.Elasticsearch do upvoter_ids: image.upvoters |> Enum.map(& &1.id), downvoter_ids: image.downvoters |> Enum.map(& &1.id), deleted_by_user_id: image.deleter_id, + duplicate_id: image.duplicate_id, galleries: image.gallery_interactions |> Enum.map(&%{id: &1.gallery_id, position: &1.position}), namespaced_tags: %{ diff --git a/lib/philomena_web/image_loader.ex b/lib/philomena_web/image_loader.ex index e67f94c4..6b4125a8 100644 --- a/lib/philomena_web/image_loader.ex +++ b/lib/philomena_web/image_loader.ex @@ -73,6 +73,9 @@ defmodule PhilomenaWeb.ImageLoader do defp maybe_show_deleted(filters, true, "only"), do: [%{term: %{hidden_from_users: false}} | filters] + defp maybe_show_deleted(filters, true, "deleted"), + do: [%{term: %{hidden_from_users: false}}, %{exists: %{field: :duplicate_id}} | filters] + defp maybe_show_deleted(filters, true, _param), do: [%{term: %{hidden_from_users: true}} | filters] diff --git a/lib/philomena_web/templates/image/_deleted_toggle.html.slime b/lib/philomena_web/templates/image/_deleted_toggle.html.slime index 6473da35..ae43d625 100644 --- a/lib/philomena_web/templates/image/_deleted_toggle.html.slime +++ b/lib/philomena_web/templates/image/_deleted_toggle.html.slime @@ -23,3 +23,9 @@ i.fa.fa-minus i.fa.fa-exclamation> span.hide-mobile.hide-limited-desktop Hide Deleted + += if del != "deleted" do + a href=@route.(Keyword.put(@params, :del, "deleted")) title="Only Deleted (Strict)" + i.fa.fa-minus + i.fa.fa-object-group> + span.hide-mobile.hide-limited-desktop Exclude Merges diff --git a/lib/philomena_web/templates/layout/_header.html.slime b/lib/philomena_web/templates/layout/_header.html.slime index 289fce2d..7c35e372 100644 --- a/lib/philomena_web/templates/layout/_header.html.slime +++ b/lib/philomena_web/templates/layout/_header.html.slime @@ -20,7 +20,7 @@ header.header input type="hidden" name="sd" value=@conn.params["sd"] = if hides_images?(@conn) do - = select f, :del, [{"-D", ""}, {"+D", 1}, {"DO", "only"}], name: "del", class: "input header__input", autocomplete: "off" + = select f, :del, [{"-D", ""}, {"+D", 1}, {"*D", "deleted"}, {"DO", "only"}], name: "del", class: "input header__input", autocomplete: "off" button.header__search__button type="submit" title="Search" i.fa-embedded--search