Class: SagaForge::Dashboard::StalledController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/saga_forge/dashboard/stalled_controller.rb

Overview

Instances (across every saga class) with at least one event parked in :stalled, it exhausted its retry budget and is waiting to be retried.

Constant Summary collapse

CAP =

Bound the scan: at scale there can be a large backlog, so we examine at most CAP (most recently updated first) rather than the whole table.

500

Instance Method Summary collapse

Instance Method Details

#indexObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/saga_forge/dashboard/stalled_controller.rb', line 10

def index
  @states = SagaForge::State.stalled.order(updated_at: :desc).limit(CAP).to_a
  @capped = @states.size == CAP

  # Single batched query keyed by saga_forge_state_id, grouped in Ruby,
  # instead of one query per row (N+1 at CAP=500 rows).
  @event_names = SagaForge::Event.stalled
    .where(saga_forge_state_id: @states.map(&:id))
    .ledger_order
    .pluck(:saga_forge_state_id, :event_name)
    .each_with_object(Hash.new { |h, k| h[k] = [] }) { |(id, name), acc| acc[id] << name }

  # The list is cross-class, but bulk retry is scoped to one class (the
  # BulkRecoveryJob derives its scope from State.for_saga(klass)), so
  # offer one "retry all" button per distinct class present here.
  @saga_classes = @states.map(&:saga_class).uniq.sort
end