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
5 years ago
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use functional style for tags finder
parent
4667b20c
No related merge requests found
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
end
def
execute
@tags
=
::
ActsAsTaggableOn
::
Tag
.
all
tags
=
all_tags
tags
=
filter_by_name
(
tags
)
limit
(
tags
)
end
search!
limit!
private
@tags
def
all_tags
::
ActsAsTaggableOn
::
Tag
.
all
end
def
search!
search
=
@params
[
:search
]
return
unless
search
def
filter_by_name
(
tags
)
return
tags
unless
search
return
tags
.
none
if
search
.
empty?
if
search
.
empty?
@tags
=
::
ActsAsTaggableOn
::
Tag
.
none
return
if
search
.
length
>=
Gitlab
::
SQL
::
Pattern
::
MIN_CHARS_FOR_PARTIAL_MATCHING
tags
.
named_like
(
search
)
else
tags
.
named
(
search
)
end
end
@tags
=
if
search
.
length
>=
Gitlab
::
SQL
::
Pattern
::
MIN_CHARS_FOR_PARTIAL_MATCHING
@tags
.
named_like
(
search
)
else
@tags
.
named
(
search
)
end
def
limit
(
tags
)
tags
.
limit
(
LIMIT
)
# rubocop: disable CodeReuse/ActiveRecord
end
def
limit!
@
tags
=
@tags
.
limit
(
LIMIT
)
# rubocop: disable CodeReuse/ActiveRecord
def
search
@
params
[
:search
]
end
end
end
...
...
This diff is collapsed.
Click to expand it.
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