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

pulibrary / orangelight / 5c5fd8cc-c42a-44cb-88c5-ff68a1eb5f3a

16 Jul 2025 10:42PM UTC coverage: 95.366% (-0.001%) from 95.367%
5c5fd8cc-c42a-44cb-88c5-ff68a1eb5f3a

Pull #4962

circleci

web-flow
Merge pull request #4992 from pulibrary/library_display-search-results

Display only the library name in search results
Pull Request #4962: Orangelight pos workcycle 07-07-2025

88 of 92 new or added lines in 15 files covered. (95.65%)

1 existing line in 1 file now uncovered.

6051 of 6345 relevant lines covered (95.37%)

1513.59 hits per line

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

86.36
/app/helpers/holdings_helper.rb
1
# frozen_string_literal: false
2

3
# rubocop:disable Metrics/ModuleLength
4
module HoldingsHelper
3✔
5
  # Generate the markup block for individual search result items containing holding information
6
  # @param document [SolrDocument] the Solr Document retrieved in the search result set
7
  # @return [String] the markup
8

9
  def holding_block_search(document)
3✔
10
    block = ''.html_safe
821✔
11
    holdings_hash = document.holdings_all_display
821✔
12
    @scsb_multiple = false
821✔
13

14
    holdings_hash.first(2).each do |id, holding|
821✔
15
      block << first_two_holdings_block(document, id, holding)
751✔
16
    end
17

18
    block << controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
821✔
19

20
    if @scsb_multiple == true || holdings_hash.length > 2
821✔
21
      block << view_record_for_full_avail_li(document)
46✔
22
    elsif !holdings_hash.empty?
775✔
23
      block << view_record_for_full_avail_li_two(document)
640✔
24
    end
25

26
    if block.empty?
821✔
27
      content_tag(:div, t('blacklight.holdings.search_missing'))
39✔
28
    else
29
      content_tag(:ul, block)
782✔
30
    end
31
  end
32

33
  # rubocop:disable Metrics/MethodLength
34
  # Currently having trouble breaking up this method further due to the "check_availability" variable
35
  def first_two_holdings_block(document, id, holding)
3✔
36
    location = holding_location(holding)
751✔
37
    check_availability = render_availability?
751✔
38
    accumulator = ''.html_safe
751✔
39
    if holding['library'] == 'Online'
751✔
40
      rendered_online_holdings_block = controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
×
NEW
41
      return rendered_online_holdings_block if rendered_online_holdings_block.present?
×
42

43
      check_availability = render_availability?
×
NEW
44
      accumulator << empty_link_online_holding_block
×
45

46
    else
47
      if holding['dspace'] || holding['location_code'] == 'rare$num'
751✔
48
        check_availability = false
25✔
49
        accumulator << dspace_or_numismatics_holding_block
25✔
50
      elsif /^scsb.+/.match? location[:code]
726✔
51
        check_availability = false
9✔
52
        unless holding['items'].nil?
9✔
53
          @scsb_multiple = true unless holding['items'].one?
9✔
54
          accumulator << scsb_item_block(holding)
9✔
55
        end
56
      elsif holding['dspace'].nil?
717✔
57
        accumulator << dspace_not_defined_block(location)
717✔
58
      else
59
        check_availability = false
×
60
        accumulator << under_embargo_block
×
61
      end
62
      accumulator << library_location_div(holding, document, id)
751✔
63
    end
64
    holding_status_li(accumulator, document, check_availability, id, holding)
751✔
65
  end
66
  # rubocop:enable Metrics/MethodLength
67

68
  def empty_link_online_holding_block
3✔
69
    data = content_tag(
×
70
      :span,
71
      'Link Missing',
72
      class: 'availability-icon badge bg-secondary'
73
    )
74
    data << content_tag(
×
75
      :div,
76
      'Online access is not currently available.',
77
      class: 'library-location'
78
    )
79
  end
80

81
  def onsite_access_span
3✔
82
    content_tag(
2✔
83
      :span,
84
      'On-site access',
85
      class: 'availability-icon badge bg-success'
86
    )
87
  end
88

89
  def available_access_span
3✔
90
    content_tag(
25✔
91
      :span,
92
      'Available',
93
      class: 'availability-icon badge bg-success'
94
    )
95
  end
96

97
  def dspace_or_numismatics_holding_block
3✔
98
    available_access_span
25✔
99
  end
100

101
  def scsb_item_block(holding)
3✔
102
    scsb_supervised_items?(holding) ? scsb_supervised_item : scsb_unsupervised_item(holding)
9✔
103
  end
104

105
  def scsb_supervised_item
3✔
106
    onsite_access_span
2✔
107
  end
108

109
  def scsb_unsupervised_item(holding)
3✔
110
    content_tag(
7✔
111
      :span,
112
      '',
113
      class: 'availability-icon badge',
114
      data: {
115
        'scsb-availability': 'true',
116
        'scsb-barcode': holding['items'].first['barcode'].to_s
117
      }
118
    )
119
  end
120

121
  def dspace_not_defined_block(_location)
3✔
122
    content_tag(
717✔
123
      :span,
124
      'Loading...',
125
      class: 'availability-icon badge bg-secondary'
126
    )
127
  end
128

129
  def under_embargo_block
3✔
NEW
130
    content_tag(
×
131
      :span,
132
      'Unavailable',
133
      class: 'availability-icon badge bg-danger'
134
    )
135
  end
136

137
  def library_location_div(holding, document, id)
3✔
138
    content_tag(
751✔
139
      :div,
140
      search_location_display(holding),
141
      class: 'library-location',
142
      data: {
143
        location: true,
144
        record_id: document['id'],
145
        holding_id: id
146
      }
147
    )
148
  end
149

150
  def holding_status_li(accumulator, document, check_availability, id, holding)
3✔
151
    location = holding_location(holding)
751✔
152
    content_tag(
751✔
153
      :li,
154
      accumulator,
155
      class: 'holding-status',
156
      data: {
157
        availability_record: check_availability,
158
        record_id: document['id'],
159
        holding_id: id,
160
        temp_location_code: holding['temp_location_code'],
161
        aeon: aeon_location?(location),
162
        bound_with: document.bound_with?
163
      }.compact
164
    )
165
  end
166

167
  def view_record_for_full_avail_li(document)
3✔
168
    content_tag(
46✔
169
      :li,
170
      link_to(
171
        'Available',
172
        solr_document_path(document['id']),
173
        class: 'availability-icon badge bg-secondary more-info'
174
      )
175
    )
176
  end
177

178
  def view_record_for_full_avail_li_two(document)
3✔
179
    content_tag(
640✔
180
      :li,
181
      link_to(
182
        '',
183
        solr_document_path(document['id']),
184
        class: 'availability-icon more-info'
185
      ),
186
      class: 'empty',
187
      data: { record_id: document['id'] }
188
    )
189
  end
190
end
191
# rubocop:enable Metrics/ModuleLength
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