Class: SpreeCmCommissioner::Guests::PreloadCheckInSessionIds

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree_cm_commissioner/guests/preload_check_in_session_ids.rb

Instance Method Summary collapse

Instance Method Details

#call(event:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/spree_cm_commissioner/guests/preload_check_in_session_ids.rb', line 6

def call(event:)
  return failure(nil, 'Event cannot be blank') if event.blank?

  event.guests
       .includes(event: { check_in_sessions: :check_in_rules })
       .find_each(batch_size: 100) do |guest|
    guest.preload_eligible_check_in_session_ids
    guest.save(validate: false) # Skip validations for performance
  end

  success(true)
rescue StandardError => e
  failure(nil, e.message)
end