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

pulibrary / allsearch_api / a8d8fc0f-d218-4ff0-8a65-91e6d0e0bf83

02 Dec 2025 04:00PM UTC coverage: 99.903%. Remained the same
a8d8fc0f-d218-4ff0-8a65-91e6d0e0bf83

push

circleci

web-flow
Merge pull request #414 from pulibrary/query-in-rom

Re-implement library database full text search in ROM-rb

29 of 29 new or added lines in 3 files covered. (100.0%)

68 existing lines in 12 files now uncovered.

1035 of 1036 relevant lines covered (99.9%)

105.75 hits per line

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

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

3
# This class is responsible for storing and retrieving relevant
4
# metadata from the library_staff_record table in the database
5
class LibraryStaffRecord < ApplicationRecord
3✔
6
  validates :puid, :netid, :name, :email, :title, :library_title, presence: true
3✔
7

8
  where_sql = <<~SQL.squish
3✔
9
    name_searchable @@ websearch_to_tsquery('unaccented_simple_dict', ?)
10
    OR searchable @@ websearch_to_tsquery('unaccented_dict', ?)
11
  SQL
12

13
  order_sql = <<~SQL.squish
3✔
14
    ts_rank(name_searchable, websearch_to_tsquery('unaccented_simple_dict', unaccent(?))) +
15
    ts_rank(searchable, websearch_to_tsquery('unaccented_dict', unaccent(?)))
16
  SQL
17

18
  scope :query, lambda { |search_term|
3✔
UNCOV
19
                  where(
24✔
20
                    Arel.sql(where_sql, search_term, search_term)
21
                  ).order(
22
                    Arel.sql(order_sql, search_term, search_term).desc
23
                  )
24
                }
25

26
  # :reek:TooManyStatements
27
  # rubocop:disable Metrics/AbcSize
28
  # rubocop:disable Metrics/MethodLength
29
  def self.new_from_csv(row)
3✔
30
    title = row[13]
196✔
31

32
    record = LibraryStaffRecord.new
196✔
33
    record.puid = row[0]
196✔
34
    record.netid = row[1]
196✔
35
    record.phone = row[2]
196✔
36
    record.name = row[3]
196✔
37
    record.last_name = row[4]
196✔
38
    record.first_name = row[5]
196✔
39
    record.email = row[6]
196✔
40
    record.office = row[7] # This is called "Address" in the original CSV and Airtable
196✔
41
    record.building = row[8]
196✔
42
    record.department = row[9]
196✔
43
    record.unit = row[11]
196✔
44
    record.areas_of_study = row[14]&.gsub('//', ', ')
196✔
45
    record.bio = row[16]
196✔
46
    record.my_scheduler_link = row[18]
196✔
47
    record.other_entities = row[19]&.gsub('//', ', ')
196✔
48
    record.library_title = title
196✔
49
    record.title = title
196✔
50
    record.pronouns = row[20]
196✔
51
    valid = record.valid?
196✔
52
    record.save! if valid
196✔
53
    record if valid
196✔
54
  end
55
  # rubocop:enable Metrics/AbcSize
56
  # rubocop:enable Metrics/MethodLength
57
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