Class: Assistant::TechnicalSupport::CaseEventStream::Redactor::KnownValues

Inherits:
Object
  • Object
show all
Defined in:
app/services/assistant/technical_support/case_event_stream/redactor/known_values.rb

Overview

Enumerates identifiers already attached to a case so the redactor can remove
exact values in addition to matching generic email/phone/address patterns.

Constant Summary collapse

ADDRESS_ATTRIBUTES =
%i[
  person_name_override company_name_override street1 street2 street3
  city region state_code zip address_text normalized_address
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(graph, known_people_class: Assistant::TechnicalSupport::CaseEventStream::Redactor::KnownPeople) ⇒ KnownValues

Returns a new instance of KnownValues.



11
12
13
14
15
16
17
# File 'app/services/assistant/technical_support/case_event_stream/redactor/known_values.rb', line 11

def initialize(
  graph,
  known_people_class: Assistant::TechnicalSupport::CaseEventStream::Redactor::KnownPeople
)
  @graph = graph
  @known_people = known_people_class.new(graph)
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
27
# File 'app/services/assistant/technical_support/case_event_stream/redactor/known_values.rb', line 19

def call
  values = known_people.call + address_redactions + reference_redactions
  values
    .select do |value, _replacement, match_mode|
      value.present? && (value.length >= 3 || match_mode.in?(%i[name token]))
    end
    .uniq
    .sort_by { |value, _replacement, _match_mode| -value.length }
end