Skip to content

Commit

Permalink
Fix bug in set_search_options
Browse files Browse the repository at this point in the history
Array#select always returns an array. Because of that the second part
of the condition would always evaluate to true.
Using `any?` solves the issue. And since `any?` returns with the first
match this also reduces the execution time.
  • Loading branch information
bgeuken committed Jun 9, 2018
1 parent 1e89325 commit 7e76423
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/obs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def parse_distribution(element)

def set_search_options
@search_term = params[:q] || ""
@baseproject = if cookies[:baseproject] && @distributions.select { |d| d[:project] == cookies[:baseproject] }
@baseproject = if cookies[:baseproject] && @distributions.any? { |d| d[:project] == cookies[:baseproject] }
cookies[:baseproject]
else
"openSUSE:Factory"
Expand Down

0 comments on commit 7e76423

Please sign in to comment.