I belive that you can refactor these if-statemets like this (for example):
```ruby
if user
  user_events = user.events.where(private: true)
  user_events += user.events.where(name : Regexp...) if params[:search]
  events += user_events.uniq
end
```