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
8f20f89c
Commit
8f20f89c
authored
Jul 10, 2020
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filter by open and closed state
for Jira issues
parent
67fdd183
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
app/services/jira/jql_builder_service.rb
app/services/jira/jql_builder_service.rb
+16
-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 @
8f20f89c
...
...
@@ -13,6 +13,7 @@ module Jira
@search
=
params
[
:search
]
@labels
=
params
[
:labels
]
@status
=
params
[
:status
]
@state
=
params
[
:state
]
@reporter
=
params
[
:author_username
]
@assignee
=
params
[
:assignee_username
]
@sort
=
params
[
:sort
]
||
DEFAULT_SORT
...
...
@@ -28,7 +29,7 @@ module Jira
private
attr_reader
:jira_project_key
,
:sort
,
:sort_direction
,
:search
,
:labels
,
:status
,
:reporter
,
:assignee
attr_reader
:jira_project_key
,
:sort
,
:sort_direction
,
:search
,
:labels
,
:status
,
:reporter
,
:assignee
,
:state
def
jql_filters
[
...
...
@@ -37,6 +38,7 @@ module Jira
by_status
,
by_reporter
,
by_assignee
,
by_open_and_closed
,
by_summary_and_description
].
compact
.
join
(
' AND '
)
end
...
...
@@ -80,6 +82,19 @@ module Jira
%Q[assignee = "
#{
escape_quotes
(
assignee
)
}
"]
end
def
by_open_and_closed
return
if
state
.
blank?
case
state
when
'opened'
%q[statusCategory != Done]
when
'closed'
%q[statusCategory = Done]
else
return
end
end
def
escape_quotes
(
param
)
param
.
gsub
(
'\\'
,
'\\\\\\'
).
gsub
(
'"'
,
'\\"'
)
end
...
...
spec/services/jira/jql_builder_service_spec.rb
View file @
8f20f89c
...
...
@@ -85,5 +85,29 @@ RSpec.describe Jira::JqlBuilderService do
expect
(
subject
).
to
eq
(
'project = PROJECT_KEY order by updated ASC'
)
end
end
context
'with opened state param'
do
let
(
:params
)
{
{
state:
'opened'
}
}
it
'builds jql'
do
expect
(
subject
).
to
eq
(
'project = PROJECT_KEY AND statusCategory != Done order by created DESC'
)
end
end
context
'with closed state param'
do
let
(
:params
)
{
{
state:
'closed'
}
}
it
'builds jql'
do
expect
(
subject
).
to
eq
(
'project = PROJECT_KEY AND statusCategory = Done order by created DESC'
)
end
end
context
'with any other state param'
do
let
(
:params
)
{
{
state:
'all'
}
}
it
'builds jql'
do
expect
(
subject
).
to
eq
(
'project = PROJECT_KEY order by created DESC'
)
end
end
end
end
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