Skip to content

Commit

Permalink
Merge pull request #138 from pulibrary/create-import-method
Browse files Browse the repository at this point in the history
Create import method for GuideCard and SubGuideCard images
  • Loading branch information
hackartisan committed Sep 1, 2023
2 parents 95ad1a2 + 4237443 commit 234cb76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/services/card_image_loading_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ def initialize(progressbar: nil)
@progressbar = progressbar || ProgressBar.create(format: "\e[1;35m%t: |%B|\e[0m")
end

def import
@progressbar = ProgressBar.create(format: "\e[1;35m%t: |%B|\e[0m")
import_guide_card_images
@progressbar = ProgressBar.create(format: "\e[1;35m%t: |%B|\e[0m")
import_sub_guide_images
end

# For each SubGuideCard, take its path and query s3 to get all of the image names
# for that path. For each image file, create a CardImage object with the path and
# image name.
Expand Down
12 changes: 12 additions & 0 deletions spec/services/card_image_loading_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,16 @@
cils.import_sub_guide_images
expect(cils.progressbar.to_h['percentage']).to eq 100
end

it 'imports both GuideCard and SubGuideCard images' do
expect(GuideCard.count).to eq 0
expect(SubGuideCard.count).to eq 0
gcls.import
expect(GuideCard.count).to eq 12
sgls.import
expect(SubGuideCard.count).to eq 7
expect(CardImage.count).to eq 0
cils.import
expect(CardImage.count).to eq 38
end
end

0 comments on commit 234cb76

Please sign in to comment.