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

pulibrary / allsearch_api / 8cca27ea-0ec0-4546-b1e5-0dc9f1ef05a3

31 Oct 2025 06:27PM UTC coverage: 99.903% (+0.003%) from 99.9%
8cca27ea-0ec0-4546-b1e5-0dc9f1ef05a3

Pull #389

circleci

sandbergja
Replace uses of the Banner ActiveRecord model with Rom-RB

The ActiveRecord model is still used in tests and a database migration,
maybe those could be migrated to Rom-RB in a separate PR?

A Rom Container is created that uses the same database connections as
ActiveRecord.  This allows rom to use the same database transactions
as activerecord, allowing tests (which use db transactions to stay
isolated from one another) to still pass.
Pull Request #389: Replace uses of the Banner ActiveRecord model with Rom-RB

34 of 39 new or added lines in 4 files covered. (87.18%)

57 existing lines in 13 files now uncovered.

1031 of 1032 relevant lines covered (99.9%)

112.35 hits per line

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

95.45
/app/models/article.rb
1
# frozen_string_literal: true
2

3
# This class is responsible for querying the Summon API, aka "Articles+"
4
class Article
3✔
5
  include ActiveModel::API
3✔
6
  include Parsed
3✔
7
  attr_reader :query_terms, :service
3✔
8

9
  delegate :documents, to: :service_response
3✔
10

11
  def initialize(query_terms:)
3✔
UNCOV
12
    @query_terms = query_terms
26✔
UNCOV
13
    summon_config = Rails.application.config_for(:allsearch)[:summon]
26✔
UNCOV
14
    @service = Summon::Service.new(access_id: summon_config[:access_id],
26✔
15
                                   secret_key: summon_config[:secret_key])
16
  end
17

18
  # For documentation on query parameters, see https://developers.exlibrisgroup.com/summon/apis/SearchAPI/Query/Parameters/
19
  def service_response
3✔
UNCOV
20
    service.search(
81✔
21
      's.q': query_terms, # Lucene-style queries
22
      's.fvf': 'ContentType,Newspaper Article,true', # Excludes newspaper articles
23
      's.ho': 't', # Princeton holdings only
24
      's.dym': 't', # Enables Did You Mean functionality
25
      's.ps': 3 # Limits to three documents in response
26
    )
27
  rescue Summon::Transport::TransportError => error
UNCOV
28
    handle_summon_error(error)
1✔
29
  end
30

31
  def number
3✔
UNCOV
32
    service_response.record_count
20✔
33
  end
34

35
  def more_link
3✔
UNCOV
36
    URI::HTTPS.build(host: 'princeton.summon.serialssolutions.com', path: '/search',
36✔
37
                     query: service_response.query.query_string)
38
  end
39

40
  private
3✔
41

42
  # :reek:FeatureEnvy
43
  def handle_summon_error(error)
3✔
UNCOV
44
    message = if error.is_a? Summon::Transport::AuthorizationError
1✔
UNCOV
45
                'Could not authenticate to the upstream Summon service'
1✔
46
              else
47
                error.message
×
48
              end
UNCOV
49
    raise AllsearchError.new(problem: 'UPSTREAM_ERROR',
1✔
50
                             msg: message)
51
  end
52
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