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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
818b4d0a
Commit
818b4d0a
authored
May 21, 2018
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor RakeHelper to reduce complexity
parent
d331c52f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
26 deletions
+18
-26
lib/gitlab/hashed_storage/rake_helper.rb
lib/gitlab/hashed_storage/rake_helper.rb
+18
-26
No files found.
lib/gitlab/hashed_storage/rake_helper.rb
View file @
818b4d0a
...
...
@@ -5,6 +5,10 @@ module Gitlab
ENV
.
fetch
(
'BATCH'
,
200
).
to_i
end
def
self
.
listing_limit
ENV
.
fetch
(
'LIMIT'
,
500
).
to_i
end
def
self
.
project_id_batches
(
&
block
)
Project
.
with_unmigrated_storage
.
in_batches
(
of:
batch_size
,
start:
ENV
[
'ID_FROM'
],
finish:
ENV
[
'ID_TO'
])
do
|
relation
|
# rubocop: disable Cop/InBatches
ids
=
relation
.
pluck
(
:id
)
...
...
@@ -36,44 +40,32 @@ module Gitlab
def
self
.
projects_list
(
relation_name
,
relation
)
relation_count
=
relation_summary
(
relation_name
,
relation
)
return
unless
relation_count
>
0
projects
=
relation
.
with_route
limit
=
ENV
.
fetch
(
'LIMIT'
,
500
).
to_i
return
unless
relation_count
>
0
limit
=
listing_limit
$stdout
.
puts
" ! Displaying first
#{
limit
}
#{
relation_name
}
..."
if
relation_count
>
limit
counter
=
0
projects
.
find_in_batches
(
batch_size:
batch_size
)
do
|
batch
|
batch
.
each
do
|
project
|
counter
+=
1
projects
.
find_each
(
batch_size:
batch_size
).
with_index
do
|
project
,
index
|
$stdout
.
puts
" -
#{
project
.
full_path
}
(id:
#{
project
.
id
}
)"
.
color
(
:red
)
return
if
counter
>=
limit
# rubocop:disable Lint/NonLocalExitFromIterator, Cop/AvoidReturnFromBlocks
end
break
if
index
+
1
>=
limit
end
end
def
self
.
attachments_list
(
relation_name
,
relation
)
relation_count
=
relation_summary
(
relation_name
,
relation
)
limit
=
ENV
.
fetch
(
'LIMIT'
,
500
).
to_i
return
unless
relation_count
>
0
$stdout
.
puts
" ! Displaying first
#{
limit
}
#{
relation_name
}
..."
if
relation_count
>
limit
limit
=
listing_
limit
counter
=
0
relation
.
find_in_batches
(
batch_size:
batch_size
)
do
|
batch
|
batch
.
each
do
|
upload
|
counter
+=
1
$stdout
.
puts
" ! Displaying first
#{
limit
}
#{
relation_name
}
..."
if
relation_count
>
limit
relation
.
find_each
(
batch_size:
batch_size
).
with_index
do
|
upload
,
index
|
$stdout
.
puts
" -
#{
upload
.
path
}
(id:
#{
upload
.
id
}
)"
.
color
(
:red
)
return
if
counter
>=
limit
# rubocop:disable Lint/NonLocalExitFromIterator, Cop/AvoidReturnFromBlocks
end
break
if
index
+
1
>=
limit
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