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

pulibrary / orangelight / 25bfe78f-c539-4492-9179-151d22460b61

30 Aug 2024 08:17PM UTC coverage: 45.357% (-50.4%) from 95.758%
25bfe78f-c539-4492-9179-151d22460b61

push

circleci

web-flow
Merge pull request #4168 from pulibrary/left_anchor_iii

Left anchor search

23 of 23 new or added lines in 1 file covered. (100.0%)

3090 existing lines in 140 files now uncovered.

2779 of 6127 relevant lines covered (45.36%)

7.28 hits per line

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

30.61
/app/components/location_code_facet_component.rb
1
# frozen_string_literal: true
2

3
class LocationCodeFacetComponent < ViewComponent::Base
2✔
4
  include BlacklightAdvancedSearch::AdvancedHelperBehavior
2✔
5
  include Blacklight::FacetsHelperBehavior
2✔
6
  include ApplicationHelper
2✔
7

8
  attr_reader :display_facet, :label, :blacklight_config, :search_state
2✔
9

10
  def initialize(display_facet:, label:, blacklight_config:, search_state:)
2✔
UNCOV
11
    @display_facet = display_facet
×
UNCOV
12
    @label = label
×
UNCOV
13
    @blacklight_config = blacklight_config
×
UNCOV
14
    @search_state = search_state
×
15
  end
16

17
  def libraries_and_locations
2✔
UNCOV
18
    @libraries_and_locations ||= fetch_libraries_and_locations
×
19
  end
20

21
  def location_codes_by_lib(facet_items)
2✔
UNCOV
22
    locations = {}
×
UNCOV
23
    non_code_items = []
×
UNCOV
24
    facet_items.each do |item|
×
UNCOV
25
      holding_loc = Bibdata.holding_locations[item.value]
×
UNCOV
26
      holding_loc.nil? ? non_code_items << item : add_holding_loc(item, holding_loc, locations)
×
27
    end
UNCOV
28
    library_facet_values(non_code_items, locations)
×
UNCOV
29
    locations.sort.to_h
×
30
  end
31

32
    private
2✔
33

34
      def fetch_libraries_and_locations
2✔
UNCOV
35
        values = []
×
UNCOV
36
        return values if display_facet.items.blank?
×
UNCOV
37
        location_codes_by_lib(display_facet.items).each do |library, items|
×
UNCOV
38
          library_display = items['item'].nil? ? library : "#{library} (#{number_with_delimiter(items['item'].hits)})"
×
UNCOV
39
          values << {
×
40
            value: library,
41
            label: library_display,
42
            selected: facet_value_checked?(display_facet.name, library)
43
          }
UNCOV
44
          items['recap_codes'].concat(items['codes']).each do |facet_item|
×
UNCOV
45
            item_label = facet_item_presenter(blacklight_config.facet_configuration_for_field(display_facet.name), facet_item.value, display_facet.name).label
×
UNCOV
46
            values << {
×
47
              value: facet_item.value,
48
              label: item_label,
49
              selected: facet_value_checked?(display_facet.name, facet_item.value)
50
            }
51
          end
52
        end
UNCOV
53
        values << pul_facet_value
×
UNCOV
54
        values
×
55
      end
56

57
      def pul_facet_value
2✔
58
        {
UNCOV
59
          value: 'pul',
×
60
          label: 'pul',
61
          selected: facet_value_checked?(display_facet.name, 'pul')
62
        }
63
      end
64

65
      def add_holding_loc(item, holding_loc, locations)
2✔
UNCOV
66
        library = holding_loc['library']['label']
×
UNCOV
67
        add_library(library, locations)
×
UNCOV
68
        locations[library]['codes'] << item
×
UNCOV
69
        add_scsb_loc(item, holding_loc, locations)
×
70
      end
71

72
      def add_scsb_loc(item, holding_loc, locations)
2✔
UNCOV
73
        return if holding_loc['holding_library'].nil?
×
UNCOV
74
        library = holding_loc['holding_library']['label']
×
UNCOV
75
        add_library(library, locations)
×
UNCOV
76
        locations[library]['recap_codes'] << item
×
77
      end
78

79
      def add_library(library, locations)
2✔
UNCOV
80
        locations[library] = { 'codes' => [], 'recap_codes' => [] } if locations[library].nil?
×
81
      end
82

83
      def library_facet_values(non_code_items, locations)
2✔
UNCOV
84
        non_code_items.each do |item|
×
UNCOV
85
          locations[item.value]['item'] = item if locations.key?(item.value)
×
86
        end
87
      end
88
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

© 2026 Coveralls, Inc