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
83f64a99
Commit
83f64a99
authored
Jun 04, 2021
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Ci::Runner.search only match full token
It is not a documented functionality so we avoid creating a new index
parent
56fa3f3b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
16 deletions
+11
-16
app/graphql/resolvers/ci/runners_resolver.rb
app/graphql/resolvers/ci/runners_resolver.rb
+1
-1
app/models/ci/runner.rb
app/models/ci/runner.rb
+2
-7
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+1
-1
spec/graphql/resolvers/ci/runners_resolver_spec.rb
spec/graphql/resolvers/ci/runners_resolver_spec.rb
+3
-3
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+4
-4
No files found.
app/graphql/resolvers/ci/runners_resolver.rb
View file @
83f64a99
...
...
@@ -19,7 +19,7 @@ module Resolvers
argument
:search
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'Filter by t
ext present in token or description fields
.'
description:
'Filter by t
oken or text present in description field
.'
argument
:sort
,
::
Types
::
Ci
::
RunnerSortEnum
,
required:
false
,
...
...
app/models/ci/runner.rb
View file @
83f64a99
...
...
@@ -168,18 +168,13 @@ module Ci
# Searches for runners matching the given query.
#
# This method uses ILIKE on PostgreSQL.
#
# This method performs a *partial* match on tokens, thus a query for "a"
# will match any runner where the token contains the letter "a". As a result
# you should *not* use this method for non-admin purposes as otherwise users
# might be able to query a list of all runners.
# This method uses ILIKE on PostgreSQL for the description field and performs a full match on tokens.
#
# query - The search query as a String.
#
# Returns an ActiveRecord::Relation.
def
self
.
search
(
query
)
fuzzy_search
(
query
,
[
:token
,
:description
]
)
where
(
token:
query
).
or
(
fuzzy_search
(
query
,
[
:description
])
)
end
def
self
.
online_contact_time_deadline
...
...
doc/api/graphql/reference/index.md
View file @
83f64a99
...
...
@@ -336,7 +336,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| Name | Type | Description |
| ---- | ---- | ----------- |
|
<a
id=
"queryrunnerssearch"
></a>
`search`
|
[
`String`
](
#string
)
| Filter by t
ext present in token or description fields
. |
|
<a
id=
"queryrunnerssearch"
></a>
`search`
|
[
`String`
](
#string
)
| Filter by t
oken or text present in description field
. |
|
<a
id=
"queryrunnerssort"
></a>
`sort`
|
[
`CiRunnerSort`
](
#cirunnersort
)
| Sort order of results. |
|
<a
id=
"queryrunnersstatus"
></a>
`status`
|
[
`CiRunnerStatus`
](
#cirunnerstatus
)
| Filter runners by status. |
|
<a
id=
"queryrunnerstaglist"
></a>
`tagList`
|
[
`[String!]`
](
#string
)
| Filter by tags associated with the runner (comma-separated or array). |
...
...
spec/graphql/resolvers/ci/runners_resolver_spec.rb
View file @
83f64a99
...
...
@@ -154,11 +154,11 @@ RSpec.describe Resolvers::Ci::RunnersResolver do
end
end
context
'to "def"'
do
let
(
:search_term
)
{
'def'
}
context
'to "def
ghi
"'
do
let
(
:search_term
)
{
'def
ghi
'
}
it
'returns runners containing term in token'
do
is_expected
.
to
contain_exactly
(
inactive_project_runner
,
offline_project_runner
)
is_expected
.
to
contain_exactly
(
offline_project_runner
)
end
end
end
...
...
spec/models/ci/runner_spec.rb
View file @
83f64a99
...
...
@@ -873,12 +873,12 @@ RSpec.describe Ci::Runner do
expect
(
described_class
.
search
(
runner
.
token
)).
to
eq
([
runner
])
end
it
'
returns
runners with a partially matching token'
do
expect
(
described_class
.
search
(
runner
.
token
[
0
..
2
])).
to
eq
([
runner
])
it
'
does not return
runners with a partially matching token'
do
expect
(
described_class
.
search
(
runner
.
token
[
0
..
2
])).
to
be_empty
end
it
'
returns runners with a matching token regardless of the
casing'
do
expect
(
described_class
.
search
(
runner
.
token
.
upcase
)).
to
eq
([
runner
])
it
'
does not return runners with a matching token with different
casing'
do
expect
(
described_class
.
search
(
runner
.
token
.
upcase
)).
to
be_empty
end
it
'returns runners with a matching description'
do
...
...
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