From fdf53cb49568f6f772879f0a91721408ab86fc6e Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 28 Aug 2019 21:35:01 -0400 Subject: [PATCH] format --- lib/philomena/elasticsearch.ex | 8 +++++- .../controllers/image_controller.ex | 1 + .../controllers/search_controller.ex | 28 +++++++++++-------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/philomena/elasticsearch.ex b/lib/philomena/elasticsearch.ex index 0dc841f3..097b414b 100644 --- a/lib/philomena/elasticsearch.ex +++ b/lib/philomena/elasticsearch.ex @@ -25,7 +25,13 @@ defmodule Philomena.Elasticsearch do def index_document(doc) do data = unquote(definition).as_json(doc) - Elastix.Document.index(unquote(elastic_url), unquote(index_name), [unquote(doc_type)], data.id, data) + Elastix.Document.index( + unquote(elastic_url), + unquote(index_name), + [unquote(doc_type)], + data.id, + data + ) end def reindex(ecto_query, batch_size \\ 1000) do diff --git a/lib/philomena_web/controllers/image_controller.ex b/lib/philomena_web/controllers/image_controller.ex index 9db64f60..49112031 100644 --- a/lib/philomena_web/controllers/image_controller.ex +++ b/lib/philomena_web/controllers/image_controller.ex @@ -8,6 +8,7 @@ defmodule PhilomenaWeb.ImageController do def index(conn, _params) do query = conn.assigns[:compiled_filter] + images = Image.search_records( %{ diff --git a/lib/philomena_web/controllers/search_controller.ex b/lib/philomena_web/controllers/search_controller.ex index 1fac9c5c..0097a536 100644 --- a/lib/philomena_web/controllers/search_controller.ex +++ b/lib/philomena_web/controllers/search_controller.ex @@ -4,7 +4,7 @@ defmodule PhilomenaWeb.SearchController do alias Philomena.Images.{Image, Query} alias Pow.Plug - import Ecto.Query + import Ecto.Query plug ImageFilter @@ -13,19 +13,23 @@ defmodule PhilomenaWeb.SearchController do user = conn |> Plug.current_user() with {:ok, query} <- Query.compile(user, params["q"]) do - images = + images = Image.search_records( - %{ - query: %{bool: %{must: query, must_not: filter}}, - sort: %{created_at: :desc} - }, - Image |> preload(:tags) + %{ + query: %{bool: %{must: query, must_not: filter}}, + sort: %{created_at: :desc} + }, + Image |> preload(:tags) ) - render(conn, PhilomenaWeb.ImageView, "index.html", images: images, search_query: params["q"]) - else - {:error, msg} -> - render(conn, PhilomenaWeb.ImageView, "index.html", images: [], error: msg, search_query: params["q"]) - end + render(conn, PhilomenaWeb.ImageView, "index.html", images: images, search_query: params["q"]) + else + {:error, msg} -> + render(conn, PhilomenaWeb.ImageView, "index.html", + images: [], + error: msg, + search_query: params["q"] + ) + end end end