Class: SagaForge::Dashboard::StatsQuery

Inherits:
Object
  • Object
show all
Defined in:
app/queries/saga_forge/dashboard/stats_query.rb

Constant Summary collapse

CAP =
5000

Instance Method Summary collapse

Constructor Details

#initialize(saga_class:) ⇒ StatsQuery

Returns a new instance of StatsQuery.



6
7
8
# File 'app/queries/saga_forge/dashboard/stats_query.rb', line 6

def initialize(saga_class:)
  @saga_class = saga_class
end

Instance Method Details

#countsObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/queries/saga_forge/dashboard/stats_query.rb', line 10

def counts
  base = SagaForge::State.for_saga(@saga_class)
  {
    all: capped(base),
    stalled: capped(base.stalled),
    suspended: capped(base.suspended),
    compensating: capped(base.compensating),
    finalized: capped(base.finalized),
    active: capped(base.active)
  }
end

#label(n) ⇒ Object



22
# File 'app/queries/saga_forge/dashboard/stats_query.rb', line 22

def label(n) = (n >= CAP) ? "#{CAP}+" : n.to_s