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
40b004b9
Commit
40b004b9
authored
Mar 08, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CSV export minor improvements
parent
c2913dc3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
8 deletions
+10
-8
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+2
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+4
-4
app/services/issues/export_csv_service.rb
app/services/issues/export_csv_service.rb
+1
-1
lib/csv_builder.rb
lib/csv_builder.rb
+3
-3
No files found.
app/controllers/projects/issues_controller.rb
View file @
40b004b9
...
...
@@ -6,6 +6,8 @@ class Projects::IssuesController < Projects::ApplicationController
include
IssuableCollections
include
SpammableActions
prepend_before_action
:authenticate_user!
,
only:
[
:export_csv
]
before_action
:redirect_to_external_issue_tracker
,
only:
[
:index
,
:new
]
before_action
:module_enabled
before_action
:issue
,
only:
[
:edit
,
:update
,
:show
,
:referenced_merge_requests
,
...
...
app/models/concerns/issuable.rb
View file @
40b004b9
...
...
@@ -179,11 +179,11 @@ module Issuable
end
def
labels_hash
eager_load
(
:labels
).
pluck
(
:id
,
'labels.title'
).
inject
({})
do
|
memo
,
(
issue_id
,
label
)
|
memo
[
issue_id
]
||=
[]
memo
[
issue_id
]
<<
label
memo
issue_labels
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
[]
}
eager_load
(
:labels
).
pluck
(
:id
,
'labels.title'
).
each
do
|
issue_id
,
label
|
issue_labels
[
issue_id
]
<<
label
end
issue_labels
end
# Includes table keys in group by clause when sorting
...
...
app/services/issues/export_csv_service.rb
View file @
40b004b9
module
Issues
class
ExportCsvService
include
Rails
.
application
.
routes
.
url_helpers
include
Gitlab
::
Routing
.
url_helpers
include
GitlabRoutingHelper
# Target attachment size before base64 encoding
...
...
lib/csv_builder.rb
View file @
40b004b9
...
...
@@ -31,7 +31,7 @@ class CsvBuilder
tempfile
=
Tempfile
.
new
(
'csv_export'
)
csv
=
CSV
.
new
(
tempfile
)
write_csv
(
csv
)
do
write_csv
csv
,
until_condition:
->
do
truncate_after_bytes
&&
tempfile
.
size
>
truncate_after_bytes
end
...
...
@@ -86,7 +86,7 @@ class CsvBuilder
end
end
def
write_csv
(
csv
,
&
until_block
)
def
write_csv
(
csv
,
until_condition
:
)
csv
<<
headers
@collection
.
find_each
do
|
object
|
...
...
@@ -94,7 +94,7 @@ class CsvBuilder
@rows_written
+=
1
if
yield
if
until_condition
.
call
@truncated
=
true
break
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