Class: SagaForge::Dashboard::SagasQuery

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

Overview

Keyset pagination over one saga class's State rows. Orders by PK desc, pages with id < / > cursor, never COUNTs. Virtual filters compose the engine's derived scopes (stalled/suspended/compensating).

Constant Summary collapse

DEFAULT_PER =
50
MAX_PER =
200

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(saga_class:, filter: nil, correlation: nil, before: nil, after: nil, per: DEFAULT_PER) ⇒ SagasQuery

Returns a new instance of SagasQuery.



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

def initialize(saga_class:, filter: nil, correlation: nil, before: nil, after: nil, per: DEFAULT_PER)
  @saga_class = saga_class
  @filter = filter.presence
  @correlation = correlation.presence
  @before = before.presence&.to_i
  @after = after.presence&.to_i
  @per = per.to_i.clamp(1, MAX_PER)
end

Instance Attribute Details

#perObject (readonly)

Returns the value of attribute per.



23
24
25
# File 'app/queries/saga_forge/dashboard/sagas_query.rb', line 23

def per
  @per
end

Instance Method Details

#has_next?Boolean

older rows remain

Returns:

  • (Boolean)


25
26
27
28
# File 'app/queries/saga_forge/dashboard/sagas_query.rb', line 25

def has_next? # older rows remain
  load
  @has_next
end

#has_prev?Boolean

newer rows remain

Returns:

  • (Boolean)


30
31
32
33
# File 'app/queries/saga_forge/dashboard/sagas_query.rb', line 30

def has_prev? # newer rows remain
  load
  @has_prev
end

#next_cursorObject



35
# File 'app/queries/saga_forge/dashboard/sagas_query.rb', line 35

def next_cursor = records.last&.id

#prev_cursorObject



36
# File 'app/queries/saga_forge/dashboard/sagas_query.rb', line 36

def prev_cursor = records.first&.id

#recordsObject



19
20
21
22
# File 'app/queries/saga_forge/dashboard/sagas_query.rb', line 19

def records
  load
  @records
end