From caeb5148e1c25f98a866a8abe791c5f565aacb8d Mon Sep 17 00:00:00 2001 From: Kerdo Kurs <kerdokurs@gmail.com> Date: Tue, 10 Dec 2024 11:33:45 +0200 Subject: [PATCH] fix advanced search location splitting --- lib/proptrackr_web/controllers/search_controller.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/proptrackr_web/controllers/search_controller.ex b/lib/proptrackr_web/controllers/search_controller.ex index a4ff669..e230cc4 100644 --- a/lib/proptrackr_web/controllers/search_controller.ex +++ b/lib/proptrackr_web/controllers/search_controller.ex @@ -20,6 +20,7 @@ defmodule PropTrackrWeb.SearchController do max_rooms = from(p in Property, select: max(p.room_count)) |> Repo.one locations = from(p in Property, select: p.location) |> Repo.all + locations = locations |> Enum.filter(fn loc -> length(String.split(loc, ",")) >= 2 end) cities = Enum.map(locations, fn location -> String.split(location, ",") |> hd |> String.trim() end) cities = Enum.uniq(cities) countries = Enum.map(locations, fn location -> String.split(location, ",") |> tl |> hd |> String.trim() end) -- GitLab