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

pulibrary / orangelight / 00dbc10b-d747-4ad7-b211-7b26d753abbb

14 Aug 2025 01:25PM UTC coverage: 0.483% (-94.9%) from 95.343%
00dbc10b-d747-4ad7-b211-7b26d753abbb

push

circleci

web-flow
Merge pull request #5181 from pulibrary/dependabot/bundler/activestorage-7.2.2.2

Bump activestorage from 7.2.2.1 to 7.2.2.2

47 of 9721 relevant lines covered (0.48%)

0.01 hits per line

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

0.0
/app/models/advanced_boolean_operators.rb
1
# frozen_string_literal: true
2
# This class is responsible for reading some boolean operators
3
# (AND, OR, or NOT) from some URL query params, and translating
4
# them into the operators that Solr's BoolQParser likes (must,
5
# must_not, or should)
6
class AdvancedBooleanOperators
×
7
  def initialize(parameters)
×
8
    @parameters = parameters || ActionController::Parameters.new
×
9
  end
×
10

11
  def for_boolqparser
×
12
    parameters.without(:boolean_operator1, :boolean_operator2).deep_merge(clauses)
×
13
  end
×
14

15
    private
×
16

17
      attr_reader :parameters
×
18

19
      def first_operator
×
20
        parameters['boolean_operator1']&.upcase
×
21
      end
×
22

23
      def second_operator
×
24
        parameters['boolean_operator2']&.upcase
×
25
      end
×
26

27
      def clauses
×
28
        if first_operator.present? || second_operator.present?
×
29
          { clause: { '0': { op: first_boolqparser_param }, '1': { op: middle_boolqparser_param }, '2': { op: last_boolqparser_param } } }
×
30
        else
×
31
          {}
×
32
        end
×
33
      end
×
34

35
      def first_boolqparser_param
×
36
        return 'must' if first_operator == 'AND'
×
37
        return 'must' if first_operator == 'NOT' && second_operator != 'OR'
×
38
        'should'
×
39
      end
×
40

41
      def middle_boolqparser_param
×
42
        return 'should' if second_operator == 'OR' && first_operator != 'NOT'
×
43
        mapping = {
×
44
          'OR' => 'should',
×
45
          'NOT' => 'must_not',
×
46
          'AND' => 'must'
×
47
        }
×
48
        mapping[first_operator] || 'should'
×
49
      end
×
50

51
      def last_boolqparser_param
×
52
        mapping = {
×
53
          'OR' => 'should',
×
54
          'NOT' => 'must_not',
×
55
          'AND' => 'must'
×
56
        }
×
57
        mapping[second_operator] || 'should'
×
58
      end
×
59
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