Skip to content

Commit

Permalink
Fix search by company name and search by industry name
Browse files Browse the repository at this point in the history
  • Loading branch information
imahmedismail committed Nov 7, 2023
1 parent 911f91b commit 55aebc1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/companies/helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ defmodule Companies.Helpers do

@default_page_size "16"

def searched_list(list, _params) do
list
def searched_list(list, params) do
search_param = params["search"]["text"]
if search_param do
Enum.filter(list, fn %{name: name, industry: industry} ->
String.contains?(String.downcase(name), String.downcase(search_param)) or
String.contains?(String.downcase(industry), String.downcase(search_param))
end)
else
list
end
end

def sorted_list(list, params) do
Expand Down

0 comments on commit 55aebc1

Please sign in to comment.