Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
28fcf5c4
Commit
28fcf5c4
authored
Feb 21, 2019
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use functional style for tags finder
parent
4667b20c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
app/finders/autocomplete/acts_as_taggable_on/tags_finder.rb
app/finders/autocomplete/acts_as_taggable_on/tags_finder.rb
+19
-19
No files found.
app/finders/autocomplete/acts_as_taggable_on/tags_finder.rb
View file @
28fcf5c4
...
@@ -10,34 +10,34 @@ module Autocomplete
...
@@ -10,34 +10,34 @@ module Autocomplete
end
end
def
execute
def
execute
@tags
=
::
ActsAsTaggableOn
::
Tag
.
all
tags
=
all_tags
tags
=
filter_by_name
(
tags
)
search!
limit
(
tags
)
limit!
@tags
end
end
def
search!
private
search
=
@params
[
:search
]
return
unless
search
if
search
.
empty?
def
all_tags
@tags
=
::
ActsAsTaggableOn
::
Tag
.
none
::
ActsAsTaggableOn
::
Tag
.
all
return
end
end
@tags
=
def
filter_by_name
(
tags
)
return
tags
unless
search
return
tags
.
none
if
search
.
empty?
if
search
.
length
>=
Gitlab
::
SQL
::
Pattern
::
MIN_CHARS_FOR_PARTIAL_MATCHING
if
search
.
length
>=
Gitlab
::
SQL
::
Pattern
::
MIN_CHARS_FOR_PARTIAL_MATCHING
@
tags
.
named_like
(
search
)
tags
.
named_like
(
search
)
else
else
@tags
.
named
(
search
)
tags
.
named
(
search
)
end
end
end
def
limit
(
tags
)
tags
.
limit
(
LIMIT
)
# rubocop: disable CodeReuse/ActiveRecord
end
end
def
limit!
def
search
@
tags
=
@tags
.
limit
(
LIMIT
)
# rubocop: disable CodeReuse/ActiveRecord
@
params
[
:search
]
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment