Class: SpreeCmCommissioner::Integrations::VireakBuntham::SyncStrategies::IncrementalSyncStrategy

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

Overview

Incremental sync strategy for Vireak Buntham (VET) integration.

Picks the route with the oldest last_synced_at and syncs only today’s trips for it. Runs frequently to keep prices and seat availability fresh without triggering a full refresh each time.

Instance Method Summary collapse

Constructor Details

#initialize(integration:) ⇒ IncrementalSyncStrategy

Returns a new instance of IncrementalSyncStrategy.



8
9
10
11
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/sync_strategies/incremental_sync_strategy.rb', line 8

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

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/sync_strategies/incremental_sync_strategy.rb', line 13

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