Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
99be47f8
Unverified
Commit
99be47f8
authored
1 year ago
by
jsgoldstein
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Change searching with # to include account index (#25638)
parent
af54bf52
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/services/account_search_service.rb
+6
-2
6 additions, 2 deletions
app/services/account_search_service.rb
app/services/search_service.rb
+4
-3
4 additions, 3 deletions
app/services/search_service.rb
spec/services/search_service_spec.rb
+1
-10
1 addition, 10 deletions
spec/services/search_service_spec.rb
with
11 additions
and
15 deletions
app/services/account_search_service.rb
+
6
−
2
View file @
99be47f8
...
...
@@ -133,8 +133,12 @@ class AccountSearchService < BaseService
end
def
must_clause
fields
=
%w(username username.* display_name display_name.*)
fields
<<
'text'
<<
'text.*'
if
options
[
:use_searchable_text
]
if
options
[
:start_with_hashtag
]
fields
=
%w(text text.*)
else
fields
=
%w(username username.* display_name display_name.*)
fields
<<
'text'
<<
'text.*'
if
options
[
:use_searchable_text
]
end
[
{
...
...
This diff is collapsed.
Click to expand it.
app/services/search_service.rb
+
4
−
3
View file @
99be47f8
...
...
@@ -33,7 +33,8 @@ class SearchService < BaseService
resolve:
@resolve
,
offset:
@offset
,
use_searchable_text:
true
,
following:
@following
following:
@following
,
start_with_hashtag:
@query
.
start_with?
(
'#'
)
)
end
...
...
@@ -91,11 +92,11 @@ class SearchService < BaseService
def
full_text_searchable?
return
false
unless
Chewy
.
enabled?
statuses_search?
&&
!
@account
.
nil?
&&
!
(
(
@query
.
start_with?
(
'#'
)
||
@query
.
include?
(
'@'
)
)
&&
!
@query
.
include?
(
' '
))
statuses_search?
&&
!
@account
.
nil?
&&
!
(
@query
.
include?
(
'@'
)
&&
!
@query
.
include?
(
' '
))
end
def
account_searchable?
account_search?
&&
!
(
@query
.
start_with?
(
'#'
)
||
(
@query
.
include?
(
'@'
)
&&
@query
.
include?
(
' '
))
)
account_search?
&&
!
(
@query
.
include?
(
'@'
)
&&
@query
.
include?
(
' '
))
end
def
hashtag_searchable?
...
...
This diff is collapsed.
Click to expand it.
spec/services/search_service_spec.rb
+
1
−
10
View file @
99be47f8
...
...
@@ -68,7 +68,7 @@ describe SearchService, type: :service do
allow
(
AccountSearchService
).
to
receive
(
:new
).
and_return
(
service
)
results
=
subject
.
call
(
query
,
nil
,
10
)
expect
(
service
).
to
have_received
(
:call
).
with
(
query
,
nil
,
limit:
10
,
offset:
0
,
resolve:
false
,
use_searchable_text:
true
,
following:
false
)
expect
(
service
).
to
have_received
(
:call
).
with
(
query
,
nil
,
limit:
10
,
offset:
0
,
resolve:
false
,
start_with_hashtag:
false
,
use_searchable_text:
true
,
following:
false
)
expect
(
results
).
to
eq
empty_results
.
merge
(
accounts:
[
account
])
end
end
...
...
@@ -92,15 +92,6 @@ describe SearchService, type: :service do
expect
(
Tag
).
to_not
have_received
(
:search_for
)
expect
(
results
).
to
eq
empty_results
end
it
'does not include account when starts with # character'
do
query
=
'#tag'
allow
(
AccountSearchService
).
to
receive
(
:new
)
results
=
subject
.
call
(
query
,
nil
,
10
)
expect
(
AccountSearchService
).
to_not
have_received
(
:new
)
expect
(
results
).
to
eq
empty_results
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment