Commit 5d9b5118 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'jej/add-weight-to-csv-export' into 'master'

Issue export CSV includes "Weight" and "Locked"

Closes #2172 and #2287

See merge request gitlab-org/gitlab-ee!5300
parents f04bf8a9 6dcb5d1b
...@@ -39,6 +39,8 @@ You will be asked to confirm the number of issues and email address for the expo ...@@ -39,6 +39,8 @@ You will be asked to confirm the number of issues and email address for the expo
## Format ## Format
> **Time Estimate** and **Time Spent** columns were [introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2627) in GitLab Starter 10.0. > **Time Estimate** and **Time Spent** columns were [introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2627) in GitLab Starter 10.0.
>
> **Weight** and **Locked** columns were [introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/5300) in GitLab Starter 10.8.
Data will be encoded with a comma as the column delimiter, with `"` used to quote fields if needed, and newlines to separate rows. The first row will be the headers, which are listed in the following table along with a description of the values: Data will be encoded with a comma as the column delimiter, with `"` used to quote fields if needed, and newlines to separate rows. The first row will be the headers, which are listed in the following table along with a description of the values:
...@@ -55,10 +57,12 @@ Data will be encoded with a comma as the column delimiter, with `"` used to quot ...@@ -55,10 +57,12 @@ Data will be encoded with a comma as the column delimiter, with `"` used to quot
| Assignee | Full name of the issue assignee | | Assignee | Full name of the issue assignee |
| Assignee Username | Username of the author, with the `@` symbol omitted | | Assignee Username | Username of the author, with the `@` symbol omitted |
| Confidential | `Yes` or `No` | | Confidential | `Yes` or `No` |
| Locked | `Yes` or `No` |
| Due Date | Formated as `YYYY-MM-DD` | | Due Date | Formated as `YYYY-MM-DD` |
| Created At (UTC) | Formated as `YYYY-MM-DD HH:MM:SS` | | Created At (UTC) | Formated as `YYYY-MM-DD HH:MM:SS` |
| Updated At (UTC) | Formated as `YYYY-MM-DD HH:MM:SS` | | Updated At (UTC) | Formated as `YYYY-MM-DD HH:MM:SS` |
| Milestone | Title of the issue milestone | | Milestone | Title of the issue milestone |
| Weight | Issue weight |
| Labels | Title of any labels joined with a `,` | | Labels | Title of any labels joined with a `,` |
| Time Estimate | [Time estimate](../../../workflow/time_tracking.md#estimates) in seconds | | Time Estimate | [Time estimate](../../../workflow/time_tracking.md#estimates) in seconds |
| Time Spent | [Time spent](../../../workflow/time_tracking.md#time-spent) in seconds | | Time Spent | [Time spent](../../../workflow/time_tracking.md#time-spent) in seconds |
......
...@@ -38,11 +38,13 @@ module Issues ...@@ -38,11 +38,13 @@ module Issues
'Assignee' => -> (issue) { issue.assignees.map(&:name).join(', ') }, 'Assignee' => -> (issue) { issue.assignees.map(&:name).join(', ') },
'Assignee Username' => -> (issue) { issue.assignees.map(&:username).join(', ') }, 'Assignee Username' => -> (issue) { issue.assignees.map(&:username).join(', ') },
'Confidential' => -> (issue) { issue.confidential? ? 'Yes' : 'No' }, 'Confidential' => -> (issue) { issue.confidential? ? 'Yes' : 'No' },
'Locked' => -> (issue) { issue.discussion_locked? ? 'Yes' : 'No' },
'Due Date' => -> (issue) { issue.due_date&.to_s(:csv) }, 'Due Date' => -> (issue) { issue.due_date&.to_s(:csv) },
'Created At (UTC)' => -> (issue) { issue.created_at&.to_s(:csv) }, 'Created At (UTC)' => -> (issue) { issue.created_at&.to_s(:csv) },
'Updated At (UTC)' => -> (issue) { issue.updated_at&.to_s(:csv) }, 'Updated At (UTC)' => -> (issue) { issue.updated_at&.to_s(:csv) },
'Closed At (UTC)' => -> (issue) { issue.closed_at&.to_s(:csv) }, 'Closed At (UTC)' => -> (issue) { issue.closed_at&.to_s(:csv) },
'Milestone' => -> (issue) { issue.milestone&.title }, 'Milestone' => -> (issue) { issue.milestone&.title },
'Weight' => -> (issue) { issue.weight },
'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 Estimate' => ->(issue) { issue.time_estimate.to_s(:csv) },
'Time Spent' => -> (issue) { issue.timelogs.map(&:time_spent).inject(0, :+)} 'Time Spent' => -> (issue) { issue.timelogs.map(&:time_spent).inject(0, :+)}
......
---
title: Issues export CSV includes 'Weight' and 'Locked'
merge_request: 5300
author:
type: changed
...@@ -41,6 +41,8 @@ describe Issues::ExportCsvService do ...@@ -41,6 +41,8 @@ describe Issues::ExportCsvService do
created_at: DateTime.new(2015, 4, 3, 2, 1, 0), created_at: DateTime.new(2015, 4, 3, 2, 1, 0),
updated_at: DateTime.new(2016, 5, 4, 3, 2, 1), updated_at: DateTime.new(2016, 5, 4, 3, 2, 1),
closed_at: DateTime.new(2017, 6, 5, 4, 3, 2), closed_at: DateTime.new(2017, 6, 5, 4, 3, 2),
weight: 4,
discussion_locked: true,
labels: [feature_label, idea_label], labels: [feature_label, idea_label],
time_estimate: 72000) time_estimate: 72000)
issue.timelogs.create(time_spent: 360, user: user) issue.timelogs.create(time_spent: 360, user: user)
...@@ -118,6 +120,14 @@ describe Issues::ExportCsvService do ...@@ -118,6 +120,14 @@ describe Issues::ExportCsvService do
expect(csv[1]['Closed At (UTC)']).to eq nil expect(csv[1]['Closed At (UTC)']).to eq nil
end end
specify 'discussion_locked' do
expect(csv[0]['Locked']).to eq 'Yes'
end
specify 'weight' do
expect(csv[0]['Weight']).to eq '4'
end
specify 'time estimate' do specify 'time estimate' do
expect(csv[0]['Time Estimate']).to eq '72000' expect(csv[0]['Time Estimate']).to eq '72000'
expect(csv[1]['Time Estimate']).to eq '0' expect(csv[1]['Time Estimate']).to eq '0'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment