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
b93bd460
Commit
b93bd460
authored
Jan 09, 2020
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add information about epic to the csv export
- only include when the epics feature is available
parent
07dadce8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
14 deletions
+70
-14
doc/user/project/issues/csv_export.md
doc/user/project/issues/csv_export.md
+2
-0
ee/app/services/issues/export_csv_service.rb
ee/app/services/issues/export_csv_service.rb
+24
-6
ee/app/workers/export_csv_worker.rb
ee/app/workers/export_csv_worker.rb
+1
-1
ee/changelogs/unreleased/195177-epic-id-in-csv.yml
ee/changelogs/unreleased/195177-epic-id-in-csv.yml
+5
-0
ee/spec/services/issues/export_csv_service_spec.rb
ee/spec/services/issues/export_csv_service_spec.rb
+38
-7
No files found.
doc/user/project/issues/csv_export.md
View file @
b93bd460
...
...
@@ -69,6 +69,8 @@ Data will be encoded with a comma as the column delimiter, with `"` used to quot
| Labels | Title of any labels joined with a
`,`
|
| Time Estimate |
[
Time estimate
](
../time_tracking.md#estimates
)
in seconds |
| Time Spent |
[
Time spent
](
../time_tracking.md#time-spent
)
in seconds |
| Epic ID | Id of the parent epic
**(ULTIMATE)**
, introduced in 12.7 |
| Epic Title | Title of the parent epic
**(ULTIMATE)**
, introduced in 12.7 |
## Limitations
...
...
ee/app/services/issues/export_csv_service.rb
View file @
b93bd460
...
...
@@ -8,23 +8,26 @@ module Issues
# Target attachment size before base64 encoding
TARGET_FILESIZE
=
15000000
def
initialize
(
issues_relation
)
attr_reader
:project
def
initialize
(
issues_relation
,
project
)
@issues
=
issues_relation
@labels
=
@issues
.
labels_hash
@project
=
project
end
def
csv_data
csv_builder
.
render
(
TARGET_FILESIZE
)
end
def
email
(
user
,
project
)
def
email
(
user
)
Notify
.
issues_csv_email
(
user
,
project
,
csv_data
,
csv_builder
.
status
).
deliver_now
end
# rubocop: disable CodeReuse/ActiveRecord
def
csv_builder
@csv_builder
||=
CsvBuilder
.
new
(
@issues
.
preload
(
:author
,
:assignees
,
:timelogs
),
header_to_value_hash
)
CsvBuilder
.
new
(
@issues
.
preload
(
:author
,
:assignees
,
:timelogs
,
:epic
),
header_to_value_hash
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
@@ -49,10 +52,25 @@ module Issues
'Closed At (UTC)'
=>
->
(
issue
)
{
issue
.
closed_at
&
.
to_s
(
:csv
)
},
'Milestone'
=>
->
(
issue
)
{
issue
.
milestone
&
.
title
},
'Weight'
=>
->
(
issue
)
{
issue
.
weight
},
'Labels'
=>
->
(
issue
)
{
@labels
[
issue
.
id
].
sort
.
join
(
','
).
presence
},
'Labels'
=>
->
(
issue
)
{
issue_labels
(
issue
)
},
'Time Estimate'
=>
->
(
issue
)
{
issue
.
time_estimate
.
to_s
(
:csv
)
},
'Time Spent'
=>
->
(
issue
)
{
issue
.
timelogs
.
map
(
&
:time_spent
).
inject
(
0
,
:
+
)}
}
'Time Spent'
=>
->
(
issue
)
{
issue_time_spent
(
issue
)
}
}.
tap
do
|
hash
|
if
project
.
group
&
.
feature_available?
(
:epics
)
hash
[
'Epic ID'
]
=
->
(
issue
)
{
issue
.
epic
&
.
id
}
hash
[
'Epic Title'
]
=
->
(
issue
)
{
issue
.
epic
&
.
title
}
end
end
end
def
issue_labels
(
issue
)
@labels
[
issue
.
id
].
sort
.
join
(
','
).
presence
end
# rubocop: disable CodeReuse/ActiveRecord
def
issue_time_spent
(
issue
)
issue
.
timelogs
.
map
(
&
:time_spent
).
sum
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
ee/app/workers/export_csv_worker.rb
View file @
b93bd460
...
...
@@ -16,6 +16,6 @@ class ExportCsvWorker
issues
=
IssuesFinder
.
new
(
@current_user
,
params
).
execute
Issues
::
ExportCsvService
.
new
(
issues
).
email
(
@current_user
,
@project
)
Issues
::
ExportCsvService
.
new
(
issues
,
@project
).
email
(
@current_user
)
end
end
ee/changelogs/unreleased/195177-epic-id-in-csv.yml
0 → 100644
View file @
b93bd460
---
title
:
Add information about epic to Issue list csv export
merge_request
:
22662
author
:
type
:
added
ee/spec/services/issues/export_csv_service_spec.rb
View file @
b93bd460
...
...
@@ -3,11 +3,12 @@
require
'spec_helper'
describe
Issues
::
ExportCsvService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
group:
group
)
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let!
(
:bad_issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let
(
:subject
)
{
described_class
.
new
(
Issue
.
all
)
}
let
(
:subject
)
{
described_class
.
new
(
Issue
.
all
,
project
)
}
it
'renders csv to string'
do
expect
(
subject
.
csv_data
).
to
be_a
String
...
...
@@ -15,13 +16,13 @@ describe Issues::ExportCsvService do
describe
'#email'
do
it
'emails csv'
do
expect
{
subject
.
email
(
user
,
project
)
}.
to
change
(
ActionMailer
::
Base
.
deliveries
,
:count
)
expect
{
subject
.
email
(
user
)
}.
to
change
(
ActionMailer
::
Base
.
deliveries
,
:count
)
end
it
'renders with a target filesize'
do
expect
(
subject
.
csv_builder
).
to
receive
(
:render
).
with
(
described_class
::
TARGET_FILESIZE
)
subject
.
email
(
user
,
project
)
subject
.
email
(
user
)
end
end
...
...
@@ -142,12 +143,42 @@ describe Issues::ExportCsvService do
expect
(
csv
[
1
][
'Time Spent'
]).
to
eq
'0'
end
context
'handling epics'
do
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
before
do
create
(
:epic_issue
,
issue:
issue
,
epic:
epic
)
end
context
'with epics disabled'
do
it
'does not include epics information'
do
expect
(
csv
[
0
]).
not_to
have_key
(
'Epic ID'
)
end
end
context
'with epics enabled'
do
before
do
stub_licensed_features
(
epics:
true
)
end
specify
'epic ID'
do
expect
(
csv
[
0
][
'Epic ID'
]).
to
eq
(
epic
.
id
.
to_s
)
expect
(
csv
[
1
][
'Epic ID'
]).
to
be_nil
end
specify
'epic Title'
do
expect
(
csv
[
0
][
'Epic Title'
]).
to
eq
(
epic
.
title
)
expect
(
csv
[
1
][
'Epic Title'
]).
to
be_nil
end
end
end
context
'with issues filtered by labels and project'
do
let
(
:subject
)
do
described_class
.
new
(
IssuesFinder
.
new
(
user
,
project_id:
project
.
id
,
label_name:
%w(Idea Feature)
).
execute
)
label_name:
%w(Idea Feature)
).
execute
,
project
)
end
it
'returns only filtered objects'
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