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

pulibrary / allsearch_api / d95529c8-ccb8-420d-95f4-a8e613b4aa59

03 Jul 2025 12:26AM UTC coverage: 99.514% (+0.007%) from 99.507%
d95529c8-ccb8-420d-95f4-a8e613b4aa59

push

circleci

web-flow
Merge pull request #382 from pulibrary/catalog-rack-app

Migrate Catalog from Rails controller to Rack app

18 of 21 new or added lines in 2 files covered. (85.71%)

101 existing lines in 19 files now uncovered.

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

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✔
19
                  where(
34✔
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