Class: Autocomplete::RoutesFinder
- Inherits:
-
Object
- Object
- Autocomplete::RoutesFinder
- Defined in:
- app/finders/autocomplete/routes_finder.rb
Overview
Finder that returns a list of routes that match on the ‘path` attribute.
Direct Known Subclasses
Defined Under Namespace
Classes: NamespacesOnly, ProjectsOnly
Constant Summary collapse
- LIMIT =
20
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#search ⇒ Object
readonly
Returns the value of attribute search.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user, params = {}) ⇒ RoutesFinder
constructor
A new instance of RoutesFinder.
Constructor Details
#initialize(current_user, params = {}) ⇒ RoutesFinder
Returns a new instance of RoutesFinder.
10 11 12 13 |
# File 'app/finders/autocomplete/routes_finder.rb', line 10 def initialize(current_user, params = {}) @current_user = current_user @search = params[:search] end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
6 7 8 |
# File 'app/finders/autocomplete/routes_finder.rb', line 6 def current_user @current_user end |
#search ⇒ Object (readonly)
Returns the value of attribute search.
6 7 8 |
# File 'app/finders/autocomplete/routes_finder.rb', line 6 def search @search end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/finders/autocomplete/routes_finder.rb', line 15 def execute return Route.none if @search.blank? Route .for_routable(routables) .sort_by_path_length .fuzzy_search(@search, [:path]) .allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/421843') .limit(LIMIT) # rubocop: disable CodeReuse/ActiveRecord end |