diff --git a/lib/proptrackr_web/controllers/search_controller.ex b/lib/proptrackr_web/controllers/search_controller.ex index a4ff66943456055b208e588c05e1491c8a20f3ca..e230cc47c75e0728be2dfe619cc92a35bddf275a 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)