Class: NcsNavigator::Warehouse::Filters::NoSsuOutreachPlaceholderFilter
- Inherits:
-
Object
- Object
- NcsNavigator::Warehouse::Filters::NoSsuOutreachPlaceholderFilter
- Defined in:
- lib/ncs_navigator/warehouse/filters/no_ssu_outreach_placeholder_filter.rb
Overview
A filter which associates outreach event records that don't have an SSU ID with an automatically-created placeholder SSU.
This filter is intended for use when reading a center's VDR XML into the warehouse for eventual import into a new NCS Navigator instance. Some centers have outreach events which are not logically associated with any SSUs. This scenario is permitted in MDES 2.1+, but not in MDES 2.0. This filter provides a shim to allow their data to be loaded, both into the warehouse and eventually into Staff Portal. The shim will be removed after they are upgraded to MDES 2.1.
This filter is stateful and so needs to be instantiated when being added to the warehouse configuration.
Constant Summary collapse
- PLACEHOLDER_SSU_ID =
'NO_SSU_PLACEHOLDER_PRE_MDES_2_1'
Instance Method Summary collapse
- #call(records) ⇒ Object
-
#initialize(configuration) ⇒ NoSsuOutreachPlaceholderFilter
constructor
A new instance of NoSsuOutreachPlaceholderFilter.
Constructor Details
#initialize(configuration) ⇒ NoSsuOutreachPlaceholderFilter
Returns a new instance of NoSsuOutreachPlaceholderFilter.
22 23 24 25 |
# File 'lib/ncs_navigator/warehouse/filters/no_ssu_outreach_placeholder_filter.rb', line 22 def initialize(configuration) @configuration = configuration @outreach_model = configuration.models_module.const_get(:Outreach) end |
Instance Method Details
#call(records) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ncs_navigator/warehouse/filters/no_ssu_outreach_placeholder_filter.rb', line 27 def call(records) return records unless has_any_no_ssu_outreach?(records) unless @placeholder_ssu_created records.unshift(create_placeholder_ssu) @placeholder_ssu_created = true end records.each do |rec| rec.ssu_id = PLACEHOLDER_SSU_ID if is_no_ssu_outreach?(rec) end records end |