• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / imagecat-rails / 253bfc9c-46cd-4a7a-8c87-f4bdbd73a2fb

pending completion
253bfc9c-46cd-4a7a-8c87-f4bdbd73a2fb

Pull #120

circleci

leefaisonr
Fetch image file names from s3

Co-authored-by: Bess Sadler <bess@users.noreply.github.com>
Pull Request #120: Fetch image file names from s3

6 of 6 new or added lines in 1 file covered. (100.0%)

90 of 92 relevant lines covered (97.83%)

8.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/app/services/card_image_loading_service.rb
1
# frozen_string_literal: true
2

3
# Class for card image loading service
4
class CardImageLoadingService
1✔
5
  # For each SubGuideCard, take its path and query s3 to get all of the image names
6
  # for that path. For each image file, create a CardImage object with the path and
7
  # image name.
8
  def import
1✔
9
    SubGuideCard.all.each do |sgc|
1✔
10
      # Get an array of all file names on s3 that start that sgc.path
11
      # For each file name
12
      image_array(sgc.path).each do |file_name|
6✔
13
        ci = CardImage.new
12✔
14
        ci.path = sgc.path
12✔
15
        ci.image_name = file_name
12✔
16
        ci.save
12✔
17
      end
18
    end
19
  end
20

21
  # returns something like
22
  # ["imagecat-disk9-0091-A3037-1358.0110.tif", "imagecat-disk9-0091-A3037-1358.0111.tif"]
23
  def image_array(path)
1✔
24
    s3_image_list(path).split("\n").map(&:split).map(&:last)
6✔
25
  end
26

27
  # returns something like
28
  # "2023-07-19 14:39:38       3422 imagecat-disk9-0091-A3037-1358.0110.tif\n2023-07-19 14:39:38       7010 imagecat-disk9-0091-A3037-1358.0111.tif\n"
29
  def s3_image_list(path)
1✔
30
    s3_query = "aws s3 ls s3://puliiif-production/imagecat-disk#{path.tr('/', '-')}"
×
31
    `#{s3_query}`
×
32
  end
33
end
34
# Next steps: to fill in s3_image_list method
35
# We should get the path from the SubGuideCard and turn it into the hyphenated format
36
# We should then use that in the `aws s3 ls` command
37
# This method should take the arguments of the SubGuideCard path
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc