Class: SpreeCmCommissioner::Integrations::Larryta::SyncStrategies::IncrementalSyncStrategy

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/integrations/larryta/sync_strategies/incremental_sync_strategy.rb

Overview

Incremental sync strategy for Larryta integration

This strategy performs incremental synchronization to keep data fresh:

  1. Find routes that haven’t been synced recently

  2. Sync schedules for today and tomorrow

  3. Update seat availability

This runs frequently (every few minutes) to keep availability data up-to-date without doing a full sync each time.

Instance Method Summary collapse

Constructor Details

#initialize(integration:) ⇒ IncrementalSyncStrategy

Returns a new instance of IncrementalSyncStrategy.



12
13
14
15
# File 'app/services/spree_cm_commissioner/integrations/larryta/sync_strategies/incremental_sync_strategy.rb', line 12

def initialize(integration:)
  @integration = integration
  @sync_result = ::SpreeCmCommissioner::Integrations::Base::SyncResult.new
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/spree_cm_commissioner/integrations/larryta/sync_strategies/incremental_sync_strategy.rb', line 17

def call
  route = find_route_to_sync
  return @sync_result unless route

  sync_trips_for_route!(route)

  @sync_result
rescue StandardError => e
  @sync_result.record_error(e)
  @sync_result
end