Class: SagaForge::Dashboard::SagasQuery
- Inherits:
-
Object
- Object
- SagaForge::Dashboard::SagasQuery
- 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
-
#per ⇒ Object
readonly
Returns the value of attribute per.
Instance Method Summary collapse
-
#has_next? ⇒ Boolean
older rows remain.
-
#has_prev? ⇒ Boolean
newer rows remain.
-
#initialize(saga_class:, filter: nil, correlation: nil, before: nil, after: nil, per: DEFAULT_PER) ⇒ SagasQuery
constructor
A new instance of SagasQuery.
- #next_cursor ⇒ Object
- #prev_cursor ⇒ Object
- #records ⇒ Object
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
#per ⇒ Object (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
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
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_cursor ⇒ Object
35 |
# File 'app/queries/saga_forge/dashboard/sagas_query.rb', line 35 def next_cursor = records.last&.id |
#prev_cursor ⇒ Object
36 |
# File 'app/queries/saga_forge/dashboard/sagas_query.rb', line 36 def prev_cursor = records.first&.id |
#records ⇒ Object
19 20 21 22 |
# File 'app/queries/saga_forge/dashboard/sagas_query.rb', line 19 def records load @records end |