Class: SourceMonitor::ImportSessions::HealthCheckBroadcaster
- Inherits:
-
Object
- Object
- SourceMonitor::ImportSessions::HealthCheckBroadcaster
- Includes:
- ActionView::RecordIdentifier
- Defined in:
- lib/source_monitor/import_sessions/health_check_broadcaster.rb
Instance Method Summary collapse
- #broadcast_progress ⇒ Object
- #broadcast_row(entry) ⇒ Object
-
#initialize(import_session) ⇒ HealthCheckBroadcaster
constructor
A new instance of HealthCheckBroadcaster.
- #progress_data ⇒ Object
- #stream_name ⇒ Object
Constructor Details
#initialize(import_session) ⇒ HealthCheckBroadcaster
Returns a new instance of HealthCheckBroadcaster.
10 11 12 |
# File 'lib/source_monitor/import_sessions/health_check_broadcaster.rb', line 10 def initialize(import_session) @import_session = import_session end |
Instance Method Details
#broadcast_progress ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/source_monitor/import_sessions/health_check_broadcaster.rb', line 29 def broadcast_progress return unless turbo_available? Turbo::StreamsChannel.broadcast_replace_to( stream_name, target: progress_target, html: render_progress ) end |
#broadcast_row(entry) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/source_monitor/import_sessions/health_check_broadcaster.rb', line 18 def broadcast_row(entry) return unless turbo_available? return unless entry Turbo::StreamsChannel.broadcast_replace_to( stream_name, target: row_target(entry), html: render_row(entry) ) end |
#progress_data ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/source_monitor/import_sessions/health_check_broadcaster.rb', line 39 def progress_data entries = health_entries total = import_session.health_check_targets.size completed = entries.count { |entry| %w[working failing].include?(entry[:health_status].to_s) } { completed: completed, total: total, pending: [ total - completed, 0 ].max, active: import_session.health_checks_active?, done: total.positive? && completed >= total } end |
#stream_name ⇒ Object
14 15 16 |
# File 'lib/source_monitor/import_sessions/health_check_broadcaster.rb', line 14 def stream_name import_session.health_stream_name end |