Class: RailsOrbit::StreamController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_orbit/stream_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/rails_orbit/stream_controller.rb', line 3

def index
  respond_to do |format|
    format.turbo_stream do
      stats = fetch_all_stats
      render turbo_stream: [
        turbo_stream.update("orbit-queue-stats",
          partial: "rails_orbit/stream/queue_stats",
          locals:  { data: stats[:queue] }),
        turbo_stream.update("orbit-cache-stats",
          partial: "rails_orbit/stream/cache_stats",
          locals:  { data: stats[:cache] }),
        turbo_stream.update("orbit-error-count",
          partial: "rails_orbit/stream/error_count",
          locals:  { count: stats[:errors] }),
      ]
    end
  end
end