Module: PartnerService::Reservations::Exports::ProgressTracker

Extended by:
ActiveSupport::Concern
Includes:
ExportConstants
Defined in:
app/services/partner_service/reservations/exports/progress_tracker.rb

Defined Under Namespace

Modules: ErrorHandler, PerformanceMonitor, PhaseManager, ProgressCalculators

Constant Summary

Constants included from ExportConstants

ExportConstants::CHANNEL_IDS_TO_SKIP, ExportConstants::DEFAULT_QUEUE, ExportConstants::EMAIL_BATCH_SIZE, ExportConstants::ERROR_CATEGORIES, ExportConstants::EXCEL_FILE_EXTENSION, ExportConstants::LARGE_DATASET_WARNING_THRESHOLD, ExportConstants::LONG_PROCESS_DAYS_THRESHOLD, ExportConstants::LONG_PROCESS_QUEUE, ExportConstants::MAX_RETRIES, ExportConstants::PDF_FILE_EXTENSION, ExportConstants::PROGRESS_MESSAGES, ExportConstants::PROGRESS_PHASES, ExportConstants::PROGRESS_UPDATE_BATCH_SIZE, ExportConstants::RESERVATION_BATCH_SIZE, ExportConstants::RETRY_BASE_INTERVAL, ExportConstants::RETRY_MAX_ELAPSED_TIME, ExportConstants::ZERO_COMMISSION_CHANNEL_ID

Instance Method Summary collapse

Instance Method Details

#create_progress_tracker(attachment, job_id = nil) ⇒ TrackingService

Create and initialize export tracker

Parameters:

  • attachment (Attachment)

    Attachment to track

  • job_id (String) (defaults to: nil)

    Sidekiq job ID

Returns:



288
289
290
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 288

def create_progress_tracker(attachment, job_id = nil)
  @export_tracker = TrackingService.new(attachment, job_id)
end

#progress_trackerTrackingService

Get current export tracker

Returns:



295
296
297
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 295

def progress_tracker
  @export_tracker
end

#update_export_progress(percentage, message = nil) ⇒ Object

Update progress with automatic phase detection

Parameters:

  • percentage (Integer)

    Progress percentage

  • message (String) (defaults to: nil)

    Progress message



322
323
324
325
326
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 322

def update_export_progress(percentage, message = nil)
  # Determine phase based on percentage
  phase = determine_phase_from_percentage(percentage)
  @export_tracker&.update_progress(phase, percentage, message)
end

#with_progress_tracking(phase, message = nil, error_category = :system_error) { ... } ⇒ Object

Execute block with progress tracking and error handling

Parameters:

  • phase (Symbol)

    Export phase

  • message (String) (defaults to: nil)

    Phase description

  • error_category (Symbol) (defaults to: :system_error)

    Error category for failures

Yields:

  • Block to execute with progress tracking



305
306
307
308
309
310
311
312
313
314
315
316
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 305

def with_progress_tracking(phase, message = nil, error_category = :system_error)
  start_phase(phase, message)

  begin
    result = yield
    complete_phase(phase)
    result
  rescue StandardError => e
    @export_tracker&.handle_error(error_category, e.message, e)
    raise e
  end
end