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
...
@@ -5,6 +5,10 @@ module Gitlab
ENV
.
fetch
(
'BATCH'
,
200
).
to_i
ENV
.
fetch
(
'BATCH'
,
200
).
to_i
end
end
def
self
.
listing_limit
ENV
.
fetch
(
'LIMIT'
,
500
).
to_i
end
def
self
.
project_id_batches
(
&
block
)
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
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
)
ids
=
relation
.
pluck
(
:id
)
...
@@ -36,44 +40,32 @@ module Gitlab
...
@@ -36,44 +40,32 @@ module Gitlab
def
self
.
projects_list
(
relation_name
,
relation
)
def
self
.
projects_list
(
relation_name
,
relation
)
relation_count
=
relation_summary
(
relation_name
,
relation
)
relation_count
=
relation_summary
(
relation_name
,
relation
)
return
unless
relation_count
>
0
projects
=
relation
.
with_route
projects
=
relation
.
with_route
limit
=
ENV
.
fetch
(
'LIMIT'
,
500
).
to_i
limit
=
listing_limit
return
unless
relation_count
>
0
$stdout
.
puts
" ! Displaying first
#{
limit
}
#{
relation_name
}
..."
if
relation_count
>
limit
$stdout
.
puts
" ! Displaying first
#{
limit
}
#{
relation_name
}
..."
if
relation_count
>
limit
counter
=
0
projects
.
find_each
(
batch_size:
batch_size
).
with_index
do
|
project
,
index
|
projects
.
find_in_batches
(
batch_size:
batch_size
)
do
|
batch
|
batch
.
each
do
|
project
|
counter
+=
1
$stdout
.
puts
" -
#{
project
.
full_path
}
(id:
#{
project
.
id
}
)"
.
color
(
:red
)
$stdout
.
puts
" -
#{
project
.
full_path
}
(id:
#{
project
.
id
}
)"
.
color
(
:red
)
return
if
counter
>=
limit
# rubocop:disable Lint/NonLocalExitFromIterator, Cop/AvoidReturnFromBlocks
break
if
index
+
1
>=
limit
end
end
end
end
end
def
self
.
attachments_list
(
relation_name
,
relation
)
def
self
.
attachments_list
(
relation_name
,
relation
)
relation_count
=
relation_summary
(
relation_name
,
relation
)
relation_count
=
relation_summary
(
relation_name
,
relation
)
limit
=
ENV
.
fetch
(
'LIMIT'
,
500
).
to_i
return
unless
relation_count
>
0
return
unless
relation_count
>
0
$stdout
.
puts
" ! Displaying first
#{
limit
}
#{
relation_name
}
..."
if
relation_count
>
limit
limit
=
listing_
limit
counter
=
0
$stdout
.
puts
" ! Displaying first
#{
limit
}
#{
relation_name
}
..."
if
relation_count
>
limit
relation
.
find_in_batches
(
batch_size:
batch_size
)
do
|
batch
|
batch
.
each
do
|
upload
|
counter
+=
1
relation
.
find_each
(
batch_size:
batch_size
).
with_index
do
|
upload
,
index
|
$stdout
.
puts
" -
#{
upload
.
path
}
(id:
#{
upload
.
id
}
)"
.
color
(
:red
)
$stdout
.
puts
" -
#{
upload
.
path
}
(id:
#{
upload
.
id
}
)"
.
color
(
:red
)
return
if
counter
>=
limit
# rubocop:disable Lint/NonLocalExitFromIterator, Cop/AvoidReturnFromBlocks
break
if
index
+
1
>=
limit
end
end
end
end
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