Module: PartnerService::Reservations::Exports::ProgressTracker::ProgressCalculators
- Defined in:
- app/services/partner_service/reservations/exports/progress_tracker.rb
Overview
Progress calculation helpers for different export phases
Instance Method Summary collapse
-
#calculate_batch_progress(current_batch, total_batches, phase = :collecting_data) ⇒ Integer
Calculate progress for data collection phase based on batch processing.
-
#calculate_email_progress(emails_sent, total_emails, phase = :sending_email) ⇒ Integer
Calculate progress for email sending based on recipients processed.
-
#calculate_row_progress(current_row, total_rows, phase = :generating_file) ⇒ Integer
Calculate progress for file generation based on rows processed.
-
#calculate_upload_progress(bytes_transferred, total_bytes, phase = :uploading_file) ⇒ Integer
Calculate progress for file upload based on bytes transferred.
Instance Method Details
#calculate_batch_progress(current_batch, total_batches, phase = :collecting_data) ⇒ Integer
Calculate progress for data collection phase based on batch processing
40 41 42 43 44 45 46 47 48 |
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 40 def calculate_batch_progress(current_batch, total_batches, phase = :collecting_data) return 0 if total_batches <= 0 phase_range = ExportConstants::PROGRESS_PHASES[phase] phase_width = phase_range.max - phase_range.min batch_progress = (current_batch.to_f / total_batches) * phase_width (phase_range.min + batch_progress).round end |
#calculate_email_progress(emails_sent, total_emails, phase = :sending_email) ⇒ Integer
Calculate progress for email sending based on recipients processed
88 89 90 91 92 93 94 95 96 |
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 88 def calculate_email_progress(emails_sent, total_emails, phase = :sending_email) return 0 if total_emails <= 0 phase_range = ExportConstants::PROGRESS_PHASES[phase] phase_width = phase_range.max - phase_range.min email_progress = (emails_sent.to_f / total_emails) * phase_width (phase_range.min + email_progress).round end |
#calculate_row_progress(current_row, total_rows, phase = :generating_file) ⇒ Integer
Calculate progress for file generation based on rows processed
56 57 58 59 60 61 62 63 64 |
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 56 def calculate_row_progress(current_row, total_rows, phase = :generating_file) return 0 if total_rows <= 0 phase_range = ExportConstants::PROGRESS_PHASES[phase] phase_width = phase_range.max - phase_range.min row_progress = (current_row.to_f / total_rows) * phase_width (phase_range.min + row_progress).round end |
#calculate_upload_progress(bytes_transferred, total_bytes, phase = :uploading_file) ⇒ Integer
Calculate progress for file upload based on bytes transferred
72 73 74 75 76 77 78 79 80 |
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 72 def calculate_upload_progress(bytes_transferred, total_bytes, phase = :uploading_file) return 0 if total_bytes <= 0 phase_range = ExportConstants::PROGRESS_PHASES[phase] phase_width = phase_range.max - phase_range.min upload_progress = (bytes_transferred.to_f / total_bytes) * phase_width (phase_range.min + upload_progress).round end |