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
d3fa6e50
Commit
d3fa6e50
authored
Feb 10, 2022
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use simple user query, rather than ReferenceExtractor
parent
3eef5691
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+11
-12
No files found.
app/services/quick_actions/interpret_service.rb
View file @
d3fa6e50
...
@@ -69,25 +69,24 @@ module QuickActions
...
@@ -69,25 +69,24 @@ module QuickActions
Gitlab
::
QuickActions
::
Extractor
.
new
(
self
.
class
.
command_definitions
)
Gitlab
::
QuickActions
::
Extractor
.
new
(
self
.
class
.
command_definitions
)
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
extract_users
(
params
)
def
extract_users
(
params
)
return
[]
if
params
.
blank?
return
[]
if
params
.
blank?
# We are using the a simple User.by_username query here rather than a ReferenceExtractor
# because the needs here are much simpler: we only deal in usernames, and
# want to also handle bare usernames. The ReferenceExtractor also has
# different behaviour, and will return all group members for groups named
# using a user-style reference, which is not in scope here.
args
=
params
.
split
(
/\s|,/
).
select
(
&
:present?
).
uniq
-
[
'and'
]
args
=
params
.
split
(
/\s|,/
).
select
(
&
:present?
).
uniq
-
[
'and'
]
users
=
extract_references
(
args
.
reject
{
_1
==
'me'
}.
join
(
' '
),
:user
)
usernames
=
(
args
-
[
'me'
]).
map
{
_1
.
delete_prefix
(
'@'
)
}
users
<<
current_user
if
args
.
include?
(
'me'
)
found
=
User
.
by_username
(
usernames
).
to_a
.
select
{
can?
(
:read_user_profile
,
_1
)
}
users
=
User
.
where
(
username:
args
).
to_a
if
users
.
empty?
found_names
=
found
.
map
(
&
:username
).
to_set
missing
=
args
.
reject
{
|
arg
|
arg
==
'me'
||
found_names
.
include?
(
arg
.
delete_prefix
(
'@'
))
}.
map
{
"'
#{
_1
}
'"
}
users
.
select!
{
can?
(
:read_user_profile
,
_1
)
}
usernames
=
users
.
map
(
&
:username
).
to_set
missing
=
args
.
reject
{
|
arg
|
arg
==
'me'
||
usernames
.
include?
(
arg
.
delete_prefix
(
'@'
))
}.
map
{
"'
#{
_1
}
'"
}
failed_parse
(
format
(
_
(
"Failed to find users for %{missing}"
),
missing:
missing
.
to_sentence
))
if
missing
.
present?
failed_parse
(
format
(
_
(
"Failed to find users for %{missing}"
),
missing:
missing
.
to_sentence
))
if
missing
.
present?
users
found
+
[
current_user
].
select
{
args
.
include?
(
'me'
)
}
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
find_milestones
(
project
,
params
=
{})
def
find_milestones
(
project
,
params
=
{})
group_ids
=
project
.
group
.
self_and_ancestors
.
select
(
:id
)
if
project
.
group
group_ids
=
project
.
group
.
self_and_ancestors
.
select
(
:id
)
if
project
.
group
...
...
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