mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-03 16:17:59 +01:00
Handle error result for API reverse search
This commit is contained in:
parent
2e88374ac1
commit
be77133136
1 changed files with 4 additions and 4 deletions
|
@ -10,17 +10,17 @@ defmodule PhilomenaWeb.Api.Json.Search.ReverseController do
|
||||||
def create(conn, %{"image" => image_params}) do
|
def create(conn, %{"image" => image_params}) do
|
||||||
user = conn.assigns.current_user
|
user = conn.assigns.current_user
|
||||||
|
|
||||||
images =
|
{images, total} =
|
||||||
image_params
|
image_params
|
||||||
|> Map.put("distance", conn.params["distance"])
|
|> Map.put("distance", conn.params["distance"])
|
||||||
|> Map.put("limit", conn.params["limit"])
|
|> Map.put("limit", conn.params["limit"])
|
||||||
|> DuplicateReports.execute_search_query()
|
|> DuplicateReports.execute_search_query()
|
||||||
|> case do
|
|> case do
|
||||||
{:ok, images} ->
|
{:ok, images} ->
|
||||||
images
|
{images, images.total_entries}
|
||||||
|
|
||||||
{:error, _changeset} ->
|
{:error, _changeset} ->
|
||||||
[]
|
{[], 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
interactions = Interactions.user_interactions(images, user)
|
interactions = Interactions.user_interactions(images, user)
|
||||||
|
@ -29,7 +29,7 @@ defmodule PhilomenaWeb.Api.Json.Search.ReverseController do
|
||||||
|> put_view(PhilomenaWeb.Api.Json.ImageView)
|
|> put_view(PhilomenaWeb.Api.Json.ImageView)
|
||||||
|> render("index.json",
|
|> render("index.json",
|
||||||
images: images,
|
images: images,
|
||||||
total: images.total_entries,
|
total: total,
|
||||||
interactions: interactions
|
interactions: interactions
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue