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
02b37c5c
Commit
02b37c5c
authored
Jul 08, 2020
by
Alexandru Croitor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add status, reporter and assignee search options
Add abiility to search by status, reporter and assignee
parent
d1c59c6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
app/services/jira/jql_builder_service.rb
app/services/jira/jql_builder_service.rb
+25
-1
spec/services/jira/jql_builder_service_spec.rb
spec/services/jira/jql_builder_service_spec.rb
+24
-0
No files found.
app/services/jira/jql_builder_service.rb
View file @
02b37c5c
...
...
@@ -12,6 +12,9 @@ module Jira
@jira_project_key
=
jira_project_key
@search
=
params
[
:search
]
@labels
=
params
[
:labels
]
@status
=
params
[
:status
]
@reporter
=
params
[
:author_username
]
@assignee
=
params
[
:assignee_username
]
@sort
=
params
[
:sort
]
||
DEFAULT_SORT
@sort_direction
=
params
[
:sort_direction
]
||
DEFAULT_SORT_DIRECTION
end
...
...
@@ -25,12 +28,15 @@ module Jira
private
attr_reader
:jira_project_key
,
:sort
,
:sort_direction
,
:search
,
:labels
attr_reader
:jira_project_key
,
:sort
,
:sort_direction
,
:search
,
:labels
,
:status
,
:reporter
,
:assignee
def
jql_filters
[
by_project
,
by_labels
,
by_status
,
by_reporter
,
by_assignee
,
by_summary_and_description
].
compact
.
join
(
' AND '
)
end
...
...
@@ -52,10 +58,28 @@ module Jira
labels
.
map
{
|
label
|
%Q[labels = "
#{
escape_quotes
(
label
)
}
"]
}.
join
(
' AND '
)
end
def
by_status
return
if
status
.
blank?
%Q[status = "
#{
escape_quotes
(
status
)
}
"]
end
def
order_by
"order by
#{
sort
}
#{
sort_direction
}
"
end
def
by_reporter
return
if
reporter
.
blank?
%Q[reporter = "
#{
escape_quotes
(
reporter
)
}
"]
end
def
by_assignee
return
if
assignee
.
blank?
%Q[assignee = "
#{
escape_quotes
(
assignee
)
}
"]
end
def
escape_quotes
(
param
)
param
.
gsub
(
'\\'
,
'\\\\\\'
).
gsub
(
'"'
,
'\\"'
)
end
...
...
spec/services/jira/jql_builder_service_spec.rb
View file @
02b37c5c
...
...
@@ -54,6 +54,30 @@ RSpec.describe Jira::JqlBuilderService do
end
end
context
'with status param'
do
let
(
:params
)
{
{
status:
"
\"
'try
\"
some'more
\"
quote'here
\"
"
}
}
it
'builds jql'
do
expect
(
subject
).
to
eq
(
"project = PROJECT_KEY AND status =
\"\\\"
'try
\\\"
some'more
\\\"
quote'here
\\\"\"
order by created DESC"
)
end
end
context
'with author_username param'
do
let
(
:params
)
{
{
author_username:
"
\"
'try
\"
some'more
\"
quote'here
\"
"
}
}
it
'builds jql'
do
expect
(
subject
).
to
eq
(
"project = PROJECT_KEY AND reporter =
\"\\\"
'try
\\\"
some'more
\\\"
quote'here
\\\"\"
order by created DESC"
)
end
end
context
'with assignee_username param'
do
let
(
:params
)
{
{
assignee_username:
"
\"
'try
\"
some'more
\"
quote'here
\"
"
}
}
it
'builds jql'
do
expect
(
subject
).
to
eq
(
"project = PROJECT_KEY AND assignee =
\"\\\"
'try
\\\"
some'more
\\\"
quote'here
\\\"\"
order by created DESC"
)
end
end
context
'with sort params'
do
let
(
:params
)
{
{
sort:
'updated'
,
sort_direction:
'ASC'
}
}
...
...
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