From be771331360cd887ab01fddbe9c3043b58eea8d4 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 10 Sep 2024 13:26:18 -0400 Subject: [PATCH] Handle error result for API reverse search --- .../controllers/api/json/search/reverse_controller.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/philomena_web/controllers/api/json/search/reverse_controller.ex b/lib/philomena_web/controllers/api/json/search/reverse_controller.ex index 13095c2e..4abe7560 100644 --- a/lib/philomena_web/controllers/api/json/search/reverse_controller.ex +++ b/lib/philomena_web/controllers/api/json/search/reverse_controller.ex @@ -10,17 +10,17 @@ defmodule PhilomenaWeb.Api.Json.Search.ReverseController do def create(conn, %{"image" => image_params}) do user = conn.assigns.current_user - images = + {images, total} = image_params |> Map.put("distance", conn.params["distance"]) |> Map.put("limit", conn.params["limit"]) |> DuplicateReports.execute_search_query() |> case do {:ok, images} -> - images + {images, images.total_entries} {:error, _changeset} -> - [] + {[], 0} end interactions = Interactions.user_interactions(images, user) @@ -29,7 +29,7 @@ defmodule PhilomenaWeb.Api.Json.Search.ReverseController do |> put_view(PhilomenaWeb.Api.Json.ImageView) |> render("index.json", images: images, - total: images.total_entries, + total: total, interactions: interactions ) end