Module: ExportConstants

Overview

Constants for export operations to avoid hard-coded values throughout the codebase. This module centralizes all configuration values used in export workers and services.

Examples:

Usage in worker

class MyExportWorker < ApplicationWorker
  include ExportConstants

  def perform
    update_progress(PROGRESS_PHASES[:collecting_data].first, 'Starting data collection...')
    reservations.find_in_batches(batch_size: RESERVATION_BATCH_SIZE) do |batch|
      # Process batch
    end
  end
end

Constant Summary collapse

PROGRESS_PHASES =

Progress phase ranges for tracking export operations Each phase represents a percentage range of completion

{
  initializing: 0..5,
  collecting_data: 5..30,
  generating_file: 30..80,
  uploading_file: 80..90,
  sending_email: 90..95,
  completed: 95..100,
}.freeze
PROGRESS_UPDATE_BATCH_SIZE =

Batch sizes for different operations

50
RESERVATION_BATCH_SIZE =
500
EMAIL_BATCH_SIZE =
40
LONG_PROCESS_QUEUE =

Queue configuration

'longprocess'
DEFAULT_QUEUE =
'default'
LONG_PROCESS_DAYS_THRESHOLD =

Thresholds for determining processing approach

3
LARGE_DATASET_WARNING_THRESHOLD =
50_000
MAX_RETRIES =

Retry configuration

2
RETRY_BASE_INTERVAL =
1
RETRY_MAX_ELAPSED_TIME =
60
CHANNEL_IDS_TO_SKIP =

Channel IDs that should be skipped in certain operations

[].freeze
ZERO_COMMISSION_CHANNEL_ID =

Special channel ID that gets 0 commission (as requested by Ravi)

1114
EXCEL_FILE_EXTENSION =

File generation constants

'.xlsx'
PDF_FILE_EXTENSION =
'.pdf'
PROGRESS_MESSAGES =

Progress message templates

{
  initializing: 'Initializing export...',
  collecting_data: 'Collecting reservation data...',
  generating_file: 'Generating export file...',
  uploading_file: 'Uploading file to storage...',
  sending_email: 'Sending email notifications...',
  completed: 'Export completed successfully',
}.freeze
ERROR_CATEGORIES =

Error categories for user-friendly error messages

{
  data_collection: 'Failed to collect reservation data',
  file_generation: 'Failed to generate export file',
  file_upload: 'Failed to upload file',
  email_sending: 'Failed to send email notifications',
  system_error: 'An unexpected error occurred',
}.freeze