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
1
Merge Requests
1
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
nexedi
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
Hide 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
)
limit
(
tags
)
end
search!
private
limit!
@tags
def
all_tags
::
ActsAsTaggableOn
::
Tag
.
all
end
end
def
search!
def
filter_by_name
(
tags
)
search
=
@params
[
:search
]
return
tags
unless
search
return
tags
.
none
if
search
.
empty?
return
unless
search
if
search
.
empty?
if
search
.
length
>=
Gitlab
::
SQL
::
Pattern
::
MIN_CHARS_FOR_PARTIAL_MATCHING
@tags
=
::
ActsAsTaggableOn
::
Tag
.
none
tags
.
named_like
(
search
)
return
else
tags
.
named
(
search
)
end
end
end
@tags
=
def
limit
(
tags
)
if
search
.
length
>=
Gitlab
::
SQL
::
Pattern
::
MIN_CHARS_FOR_PARTIAL_MATCHING
tags
.
limit
(
LIMIT
)
# rubocop: disable CodeReuse/ActiveRecord
@tags
.
named_like
(
search
)
else
@tags
.
named
(
search
)
end
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