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

pulibrary / allsearch_api / dc764cb3-fc9b-47a1-b010-56b68ecb28a7

01 Aug 2025 03:30PM UTC coverage: 99.514%. Remained the same
dc764cb3-fc9b-47a1-b010-56b68ecb28a7

push

circleci

web-flow
Merge pull request #384 from pulibrary/dependabot/bundler/nokogiri-1.18.9

Bump nokogiri from 1.18.8 to 1.18.9

1024 of 1029 relevant lines covered (99.51%)

92.23 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✔
12
    @query_terms = query_terms
21✔
13
    summon_config = Rails.application.config_for(:allsearch)[:summon]
21✔
14
    @service = Summon::Service.new(access_id: summon_config[:access_id],
21✔
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✔
20
    service.search(
61✔
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
28
    handle_summon_error(error)
1✔
29
  end
30

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

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

40
  private
3✔
41

42
  # :reek:FeatureEnvy
43
  def handle_summon_error(error)
3✔
44
    message = if error.is_a? Summon::Transport::AuthorizationError
1✔
45
                'Could not authenticate to the upstream Summon service'
1✔
46
              else
47
                error.message
×
48
              end
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