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

pulibrary / bibdata / 166d57e5-7cd2-4a93-abb1-e0b236109bef

31 Dec 2024 08:55PM UTC coverage: 90.88% (-1.1%) from 91.93%
166d57e5-7cd2-4a93-abb1-e0b236109bef

push

circleci

maxkadel
Break on purpose to check retries

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

40 existing lines in 3 files now uncovered.

3458 of 3805 relevant lines covered (90.88%)

365.05 hits per line

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

31.71
/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
3✔
6
        update_files = download_partner_updates
3✔
7
        process_partner_updates(files: update_files)
3✔
UNCOV
8
        set_generated_date
×
UNCOV
9
        log_record_fixes
×
UNCOV
10
        delete_files = download_partner_deletes
×
UNCOV
11
        process_partner_deletes(files: delete_files)
×
12
      end
13

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

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

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

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