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

pulibrary / allsearch_api / 55f37a69-f198-45d6-96dc-4272aa3cb82c

02 Dec 2025 04:55PM UTC coverage: 99.904% (+0.001%) from 99.903%
55f37a69-f198-45d6-96dc-4272aa3cb82c

Pull #415

circleci

sandbergja
Remove ActiveRecord-based LibraryDatabaseRecord class

This also improves the performance of loading Library Database metadata from Lib-jobs
by combining all creation into a single INSERT query, rather than running an INSERT
for each row in the CSV.

To confirm, I ran this benchmark before deleting the LibraryDatabaseRecord class:

```
Benchmark.ips do |b|
  library_database_repo = LibraryDatabaseRepository.new Rails.application.config.rom
  csv = CSV.read Rails.root.join('spec/fixtures/files/libjobs/library-databases.csv'), headers: true
  b.report('LibraryDatabaseRecord::new_from_csv') do
    csv.each { LibraryDatabaseRecord.new_from_csv(it)}
    library_database_repo.delete
  end

  b.report('LibraryDatabaseRepository#create_from_csv') do
    library_database_repo.create_from_csv csv
    library_database_repo.delete
  end

  b.compare!
end
```

Results:

```
Warming up --------------------------------------
LibraryDatabaseRecord::new_from_csv
                         3.000 i/100ms
LibraryDatabaseRepository#create_from_csv
                        10.000 i/100ms
Calculating -------------------------------------
LibraryDatabaseRecord::new_from_csv
                         28.764 (±27.8%) i/s   (34.77 ms/i) -    135.000 in   5.004122s
LibraryDatabaseRepository#create_from_csv
                        116.179 (±18.9%) i/s    (8.61 ms/i) -    560.000 in   5.031764s

Comparison:
LibraryDatabaseRepository#create_from_csv:      116.2 i/s
LibraryDatabaseRecord::new_from_csv:       28.8 i/s - 4.04x  slower
```

Closes #402
Pull Request #415: Remove ActiveRecord-based LibraryDatabaseRecord class

14 of 14 new or added lines in 2 files covered. (100.0%)

20 existing lines in 4 files now uncovered.

1040 of 1041 relevant lines covered (99.9%)

104.28 hits per line

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

100.0
/app/models/art_museum_document.rb
1
# frozen_string_literal: true
2

3
# This class is responsible for getting relevant
4
# metadata from the Art Museum's JSON
5
# The document is a Hash
6
class ArtMuseumDocument < Document
3✔
7
  private
3✔
8

9
  def id
3✔
UNCOV
10
    document[:_id]
84✔
11
  end
12

13
  def title
3✔
UNCOV
14
    document.dig(:_source, :displaytitle)
42✔
15
  end
16

17
  def creator
3✔
UNCOV
18
    document.dig(:_source, :displaymaker)
42✔
19
  end
20

21
  def publisher
3✔
22
    # tbd - nothing in the current json that seems relevant
23
  end
24

25
  def type
3✔
UNCOV
26
    document[:_type]
42✔
27
  end
28

29
  def description
3✔
30
    # tbd - nothing in the current json that seems relevant
31
  end
32

33
  def url
3✔
UNCOV
34
    URI::HTTPS.build(host: 'artmuseum.princeton.edu', path: "/collections/objects/#{id}")
42✔
35
  end
36

37
  def doc_keys
3✔
UNCOV
38
    [:credit_line, :medium, :dimensions, :primary_image, :object_number, :date]
42✔
39
  end
40

41
  def credit_line
3✔
UNCOV
42
    document.dig(:_source, :creditline)
42✔
43
  end
44

45
  def medium
3✔
UNCOV
46
    document.dig(:_source, :medium)
42✔
47
  end
48

49
  def dimensions
3✔
UNCOV
50
    document.dig(:_source, :dimensions)
42✔
51
  end
52

53
  def primary_image
3✔
UNCOV
54
    document.dig(:_source, :primaryimage)&.first
42✔
55
  end
56

57
  def object_number
3✔
UNCOV
58
    document.dig(:_source, :objectnumber)
42✔
59
  end
60

61
  def date
3✔
UNCOV
62
    document.dig(:_source, :displaydate)
42✔
63
  end
64

65
  def do_not_sanitize_these_fields
3✔
UNCOV
66
    super + [:primary_image]
588✔
67
  end
68
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