Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create import method for GuideCard and SubGuideCard images #138

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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