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
dd198bcb
Commit
dd198bcb
authored
Aug 07, 2017
by
Vlad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added time fields for csv export
parent
fa09edcf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
app/services/issues/export_csv_service.rb
app/services/issues/export_csv_service.rb
+4
-2
changelogs/unreleased-ee/1406-new-export-fields.yml
changelogs/unreleased-ee/1406-new-export-fields.yml
+5
-0
spec/services/issues/export_csv_service_spec.rb
spec/services/issues/export_csv_service_spec.rb
+22
-1
No files found.
app/services/issues/export_csv_service.rb
View file @
dd198bcb
...
...
@@ -21,7 +21,7 @@ module Issues
def
csv_builder
@csv_builder
||=
CsvBuilder
.
new
(
@issues
.
includes
(
:author
,
:assignees
),
header_to_value_hash
)
CsvBuilder
.
new
(
@issues
.
includes
(
:author
,
:assignees
,
:timelogs
),
header_to_value_hash
)
end
private
...
...
@@ -43,7 +43,9 @@ module Issues
'Updated At (UTC)'
=>
->
(
issue
)
{
issue
.
updated_at
&
.
to_s
(
:csv
)
},
'Closed At (UTC)'
=>
->
(
issue
)
{
issue
.
closed_at
&
.
to_s
(
:csv
)
},
'Milestone'
=>
->
(
issue
)
{
issue
.
milestone
&
.
title
},
'Labels'
=>
->
(
issue
)
{
@labels
[
issue
.
id
].
sort
.
join
(
','
).
presence
}
'Labels'
=>
->
(
issue
)
{
@labels
[
issue
.
id
].
sort
.
join
(
','
).
presence
},
'Time Estimate'
=>
->
(
issue
)
{
issue
.
time_estimate
.
to_s
(
:csv
)
},
'Time Spent'
=>
->
(
issue
)
{
issue
.
timelogs
.
map
(
&
:time_spent
).
inject
(
0
,
:
+
)}
}
end
end
...
...
changelogs/unreleased-ee/1406-new-export-fields.yml
0 → 100644
View file @
dd198bcb
---
title
:
Add Time estimate and Time spend fields in csv export
merge_request
:
2627
author
:
g3dinua, LockiStrike
type
:
changed
spec/services/issues/export_csv_service_spec.rb
View file @
dd198bcb
...
...
@@ -4,6 +4,7 @@ describe Issues::ExportCsvService do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let!
(
:bad_issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let
(
:subject
)
{
described_class
.
new
(
Issue
.
all
)
}
it
'renders csv to string'
do
...
...
@@ -40,7 +41,10 @@ describe Issues::ExportCsvService do
created_at:
DateTime
.
new
(
2015
,
4
,
3
,
2
,
1
,
0
),
updated_at:
DateTime
.
new
(
2016
,
5
,
4
,
3
,
2
,
1
),
closed_at:
DateTime
.
new
(
2017
,
6
,
5
,
4
,
3
,
2
),
labels:
[
feature_label
,
idea_label
])
labels:
[
feature_label
,
idea_label
],
time_estimate:
72000
)
issue
.
timelogs
.
create
(
time_spent:
360
,
user:
user
)
issue
.
timelogs
.
create
(
time_spent:
200
,
user:
user
)
end
specify
'iid'
do
...
...
@@ -61,6 +65,7 @@ describe Issues::ExportCsvService do
specify
'description'
do
expect
(
csv
[
0
][
'Description'
]).
to
eq
issue
.
description
expect
(
csv
[
1
][
'Description'
]).
to
eq
nil
end
specify
'author name'
do
...
...
@@ -73,10 +78,12 @@ describe Issues::ExportCsvService do
specify
'assignee name'
do
expect
(
csv
[
0
][
'Assignee'
]).
to
eq
user
.
name
expect
(
csv
[
1
][
'Assignee'
]).
to
eq
''
end
specify
'assignee username'
do
expect
(
csv
[
0
][
'Assignee Username'
]).
to
eq
user
.
username
expect
(
csv
[
1
][
'Assignee Username'
]).
to
eq
''
end
specify
'confidential'
do
...
...
@@ -85,14 +92,17 @@ describe Issues::ExportCsvService do
specify
'milestone'
do
expect
(
csv
[
0
][
'Milestone'
]).
to
eq
issue
.
milestone
.
title
expect
(
csv
[
1
][
'Milestone'
]).
to
eq
nil
end
specify
'labels'
do
expect
(
csv
[
0
][
'Labels'
]).
to
eq
'Feature,Idea'
expect
(
csv
[
1
][
'Labels'
]).
to
eq
nil
end
specify
'due_date'
do
expect
(
csv
[
0
][
'Due Date'
]).
to
eq
'2014-03-02'
expect
(
csv
[
1
][
'Due Date'
]).
to
eq
nil
end
specify
'created_at'
do
...
...
@@ -105,6 +115,17 @@ describe Issues::ExportCsvService do
specify
'closed_at'
do
expect
(
csv
[
0
][
'Closed At (UTC)'
]).
to
eq
'2017-06-05 04:03:02'
expect
(
csv
[
1
][
'Closed At (UTC)'
]).
to
eq
nil
end
specify
'time estimate'
do
expect
(
csv
[
0
][
'Time Estimate'
]).
to
eq
'72000'
expect
(
csv
[
1
][
'Time Estimate'
]).
to
eq
'0'
end
specify
'time spent'
do
expect
(
csv
[
0
][
'Time Spent'
]).
to
eq
'560'
expect
(
csv
[
1
][
'Time Spent'
]).
to
eq
'0'
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