• 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/models/scsb/partner_updates/incremental.rb
1
module Scsb
1✔
2
  class PartnerUpdates
1✔
3
    class Incremental < Update
1✔
4
      def process_incremental_files
1✔
5
        prepare_directory
×
6
        update_files = download_partner_updates
×
7
        process_partner_updates(files: update_files)
×
8
        Dump.generated_date(dump.id)
×
9
        delete_files = download_partner_deletes
×
10
        process_partner_deletes(files: delete_files)
×
11
      end
12

13
      def download_partner_updates
1✔
14
        file_list = @s3_bucket.list_files(prefix: ENV['SCSB_S3_PARTNER_UPDATES'] || 'data-exports/PUL/MARCXml/Incremental')
×
15
        @s3_bucket.download_files(files: file_list, timestamp_filter: @last_dump, output_directory: @update_directory)
×
16
      end
17

18
      def download_partner_deletes
1✔
19
        file_list = @s3_bucket.list_files(prefix: ENV['SCSB_S3_PARTNER_DELETES'] || 'data-exports/PUL/Json')
×
20
        @s3_bucket.download_files(files: file_list, timestamp_filter: @last_dump, output_directory: @update_directory)
×
21
      end
22

23
      def process_partner_deletes(files:)
1✔
24
        json_files = []
×
25
        files.each do |file|
×
26
          filename = File.basename(file, '.zip')
×
27
          file_increment = 1
×
28
          Zip::File.open(file) do |zip_file|
×
29
            zip_file.each do |entry|
×
30
              target = "#{@update_directory}/scsbdelete#{filename}_#{file_increment}.json"
×
31
              json_files << target
×
32
              entry.extract(target)
×
33
              file_increment += 1
×
34
            end
35
          end
36
          File.unlink(file)
×
37
        end
38
        ids = []
×
39
        json_files.each do |file|
×
40
          scsb_ids(file, ids)
×
41
          File.unlink(file)
×
42
        end
43
        @dump.delete_ids = ids
×
44
        @dump.save
×
45
      end
46

47
      def scsb_ids(filename, ids)
1✔
48
        file = File.read(filename)
×
49
        data = JSON.parse(file)
×
50
        data.each do |record|
×
51
          ids << "SCSB-#{record['bib']['bibId']}"
×
52
        end
53
        ids
×
54
      end
55
    end
56
  end
57
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