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

pulibrary / orangelight / 0e37073d-109c-440c-949f-49d2aa86311b

18 Aug 2025 09:05PM UTC coverage: 0.482% (-94.9%) from 95.343%
0e37073d-109c-440c-949f-49d2aa86311b

push

circleci

web-flow
Replace per_page_options_for_select with custom component to avoid deprecation issue (#5186)

* Start creating new component to address deprecaton warning

* Replace per_page_options_for_select with custom component to avoid deprecation issue

Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

---------

Co-authored-by: Ryan Jensen <rj1044@princeton.edu>
Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

0 of 33 new or added lines in 1 file covered. (0.0%)

9374 existing lines in 213 files now uncovered.

47 of 9753 relevant lines covered (0.48%)

0.01 hits per line

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

0.0
/app/models/bookmark.rb
1
# frozen_string_literal: true
2

UNCOV
3
class Bookmark < ApplicationRecord
×
UNCOV
4
  belongs_to :user, polymorphic: true
×
5

6
  # TODO: remove the following scope, since as of
7
  # migration 20230419231330, the database layer
8
  # will not allow bookmarks without a valid user
UNCOV
9
  scope :without_valid_user, -> { where('user_id NOT IN (SELECT id FROM users)') }
×
10

UNCOV
11
  def document_type
×
UNCOV
12
    SolrDocument
×
UNCOV
13
  end
×
14

UNCOV
15
  def self.destroy_without_solr_documents
×
UNCOV
16
    batch_size = Orangelight.config["bookmarks"]["batch_size"]
×
UNCOV
17
    Bookmark.find_in_batches(batch_size:).with_index do |bookmarks, batch|
×
UNCOV
18
      Rails.logger.info { "Processing destroy_without_solr_documents group ##{batch}" }
×
UNCOV
19
      bookmark_doc_ids = bookmark_doc_ids(bookmarks)
×
UNCOV
20
      doc_ids_without_solr_doc = bookmark_doc_ids - doc_ids_in_solr(bookmark_doc_ids)
×
21

UNCOV
22
      if doc_ids_without_solr_doc.present?
×
UNCOV
23
        doc_ids_without_solr_doc.each do |doc_id|
×
UNCOV
24
          Bookmark.where(document_id: doc_id)&.destroy_all
×
UNCOV
25
        end
×
UNCOV
26
      end
×
UNCOV
27
    end
×
UNCOV
28
  end
×
29

UNCOV
30
  def self.update_to_alma_ids
×
UNCOV
31
    Bookmark.where("LENGTH(document_id) <= 7").find_in_batches.with_index do |bookmarks, batch|
×
UNCOV
32
      Rails.logger.info { "Processing update_to_alma_ids group ##{batch}" }
×
UNCOV
33
      bookmarks.each do |bookmark|
×
UNCOV
34
        bookmark.document_id = bookmark.voyager_to_alma_id
×
UNCOV
35
        bookmark.save if bookmark.changed?
×
UNCOV
36
      end
×
UNCOV
37
    end
×
UNCOV
38
  end
×
39

UNCOV
40
  def self.bookmark_doc_ids(bookmarks)
×
UNCOV
41
    bookmarks.map(&:document_id).to_set
×
UNCOV
42
  end
×
43

UNCOV
44
  def self.doc_ids_in_solr(bookmark_doc_ids)
×
UNCOV
45
    solr = Blacklight.default_index.connection
×
UNCOV
46
    rows = Orangelight.config["bookmarks"]["batch_size"]
×
UNCOV
47
    response = solr.get 'select', params: { fq: "{!terms f=id}#{bookmark_doc_ids.join(',')}", fl: 'id', rows: }
×
UNCOV
48
    response["response"]["docs"].map { |doc| doc["id"] }
×
UNCOV
49
  end
×
50

UNCOV
51
  def voyager_to_alma_id
×
UNCOV
52
    return document_id if alma_id?(document_id) || special_system_id?(document_id)
×
53

UNCOV
54
    "99#{document_id}3506421"
×
UNCOV
55
  end
×
56

UNCOV
57
  private
×
58

UNCOV
59
    def alma_id?(document_id)
×
UNCOV
60
      document_id.length > 7 && document_id.start_with?("99")
×
UNCOV
61
    end
×
62

63
    # If the document_id includes letters, it is not a Voyager or Alma ID
64
    # It may be a coin, SCSB, or DSpace ID
UNCOV
65
    def special_system_id?(document_id)
×
UNCOV
66
      document_id.match?(/[a-zA-Z]/)
×
UNCOV
67
    end
×
UNCOV
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