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 b357582
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/companies/helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ 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 b357582

Please sign in to comment.