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

pulibrary / bibdata / b3c4a532-5da0-46f8-9c20-20018605a028

21 Mar 2025 08:11PM UTC coverage: 42.257% (-49.9%) from 92.185%
b3c4a532-5da0-46f8-9c20-20018605a028

push

circleci

sandbergja
Move various gems from the default Gemfile group to a more appropriate group

1599 of 3784 relevant lines covered (42.26%)

2.56 hits per line

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

20.0
/app/jobs/import/partner/download_full_file_job.rb
1
module Import
1✔
2
  module Partner
1✔
3
    class DownloadFullFileJob
1✔
4
      include Sidekiq::Job
1✔
5
      def perform(dump_id, institution, file_prefix)
1✔
6
        zip_file = Scsb::PartnerUpdates::Full.download_full_file(institution, 'zip')
×
7

8
        raise StandardError("No full dump files found matching #{institution}") unless zip_file
×
9

10
        xml_files = unzip_file(zip_file, file_prefix)
×
11
        xml_files = xml_files.to_set
×
12
        batch.jobs do
×
13
          process_xml_files_batch = Sidekiq::Batch.new
×
14
          process_xml_files_batch.description = "Process #{xml_files.size} unzipped xml files from #{institution}"
×
15
          process_xml_files_batch.on(:success, 'Import::Partner::FullCallbacks#process_xml_file_success', 'zip_file' => zip_file)
×
16
          process_xml_files_batch.jobs do
×
17
            xml_files.each do |file|
×
18
              Import::Partner::ProcessXmlFileJob.perform_async(dump_id, file)
×
19
            end
20
          end
21
        end
22
      end
23

24
      def unzip_file(file, file_prefix)
1✔
25
        update_directory = ENV.fetch('SCSB_PARTNER_UPDATE_DIRECTORY', '/tmp/updates')
×
26
        xml_files = []
×
27
        filename = File.basename(file, '.zip')
×
28
        filename.gsub!(/^[^_]+_([0-9]+)_([0-9]+).*$/, '\1_\2')
×
29
        file_increment = 1
×
30
        Zip::File.open(file) do |zip_file|
×
31
          zip_file.each do |entry|
×
32
            target = "#{update_directory}/#{file_prefix}#{filename}_#{file_increment}.xml"
×
33
            xml_files << target
×
34
            entry.extract(target)
×
35
            file_increment += 1
×
36
          # If the file already exists, we probably partially ran this job previously, and it's not a problem.
37
          # Should just move to the next entry.
38
          rescue Zip::DestinationFileExistsError => e
39
            Rails.logger.info(e.message)
×
40
          end
41
        end
42
        xml_files
×
43
      end
44
    end
45
  end
46
end
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