Skip to content

Commit

Permalink
Add progress bar implement for import task
Browse files Browse the repository at this point in the history
 Co-authored-by: Bess Sadler <bess@users.noreply.github.com>
Co-authored-by: Carolyn Cole <carolyncole@users.noreply.github.com>
 Co-authored-by: Hector Correa <hectorcorrea@users.noreply.github.com>
 Co-authored-by: James R. Griffin III <jrgriffiniii@users.noreply.github.com>
  • Loading branch information
leefaisonr committed Aug 17, 2023
1 parent 65b87af commit 8082909
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
13 changes: 5 additions & 8 deletions app/services/sub_guide_loading_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ def initialize(csv_location: nil)

def import
sub_guide_card_data = CSV.parse(File.read(csv_location), headers: true, liberal_parsing: true)
sub_guide_card_data.each do |entry|
print '#'
$stdout.flush
progressbar = ProgressBar.create
pb_increment = sub_guide_card_data.count / 100
sub_guide_card_data.each_with_index do |entry, index|
byebug
2.times { progressbar.increment }
import_sub_guide_card(entry)
end
puts 'task completed!'
end

def progressbar
100.times { progressbar.increment }
end

private
Expand Down
3 changes: 1 addition & 2 deletions spec/services/sub_guide_loading_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
end

it 'displays ruby-progress bar during import' do
progressbar = ProgressBar.create
expect { sgls.import }.to output(progressbar.increment).to_stdout
expect { sgls.import }.to output(/Progress: /).to_stdout_from_any_process
end
end

0 comments on commit 8082909

Please sign in to comment.