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

pulibrary / allsearch_api / 2edd1296-888c-4592-8789-a3202a060f6a

14 Oct 2025 05:48PM UTC coverage: 99.9% (+0.6%) from 99.32%
2edd1296-888c-4592-8789-a3202a060f6a

push

circleci

web-flow
Merge pull request #398 from pulibrary/replace-all-controllers

Replace all of our Rails controllers with Rack applications

12 of 12 new or added lines in 6 files covered. (100.0%)

116 existing lines in 19 files now uncovered.

995 of 996 relevant lines covered (99.9%)

115.81 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✔
UNCOV
30
    title = row[13]
196✔
31

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