diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2018-05-22 04:14:27 +0200 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2018-05-28 23:39:36 +0200 |
commit | b384d5e544cb2a2dea4835b43253db1c3b169992 (patch) | |
tree | 950f2d0bc487194fc78303239be72ec02f2c4907 /lib/gitlab/hashed_storage | |
parent | d17b45adf58936e52c0d97dc5bdf259f7e7ed06e (diff) | |
download | gitlab-ce-b384d5e544cb2a2dea4835b43253db1c3b169992.tar.gz |
refactor to remove duplication
Diffstat (limited to 'lib/gitlab/hashed_storage')
-rw-r--r-- | lib/gitlab/hashed_storage/rake_helper.rb | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/gitlab/hashed_storage/rake_helper.rb b/lib/gitlab/hashed_storage/rake_helper.rb index 6fcfc82459a..8aba42ccfce 100644 --- a/lib/gitlab/hashed_storage/rake_helper.rb +++ b/lib/gitlab/hashed_storage/rake_helper.rb @@ -39,31 +39,29 @@ module Gitlab end def self.projects_list(relation_name, relation) - relation_count = relation_summary(relation_name, relation) - return unless relation_count > 0 - - projects = relation.with_route - limit = listing_limit - - $stdout.puts " ! Displaying first #{limit} #{relation_name}..." if relation_count > limit - - projects.find_each(batch_size: batch_size).with_index do |project, index| + listing(relation_name, relation.with_route) do |project| $stdout.puts " - #{project.full_path} (id: #{project.id})".color(:red) - - break if index + 1 >= limit end end def self.attachments_list(relation_name, relation) + listing(relation_name, relation) do |upload| + $stdout.puts " - #{upload.path} (id: #{upload.id})".color(:red) + end + end + + def self.listing(relation_name, relation) relation_count = relation_summary(relation_name, relation) return unless relation_count > 0 limit = listing_limit - $stdout.puts " ! Displaying first #{limit} #{relation_name}..." if relation_count > limit + if relation_count > limit + $stdout.puts " ! Displaying first #{limit} #{relation_name}..." + end - relation.find_each(batch_size: batch_size).with_index do |upload, index| - $stdout.puts " - #{upload.path} (id: #{upload.id})".color(:red) + relation.find_each(batch_size: batch_size).with_index do |element, index| + yield element break if index + 1 >= limit end |