Class: ChronoForge::Dashboard::WorkflowsQuery
- Inherits:
-
Object
- Object
- ChronoForge::Dashboard::WorkflowsQuery
- Defined in:
- app/queries/chrono_forge/dashboard/workflows_query.rb
Overview
Keyset (cursor) pagination over workflows. Orders by primary key descending (newest first) and pages with ‘id < cursor` / `id > cursor` rather than OFFSET, and never issues a COUNT(*). Both degrade at scale; keyset stays constant-cost at any depth and over any number of rows. Accepts a `base` scope so it also drives bounded child lists (e.g. a branch’s children).
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(base: ChronoForge::Workflow.all, state: nil, job_class: nil, key: nil, created_from: nil, created_to: nil, before: nil, after: nil, per: DEFAULT_PER) ⇒ WorkflowsQuery
constructor
A new instance of WorkflowsQuery.
- #next_cursor ⇒ Object
- #prev_cursor ⇒ Object
- #records ⇒ Object
Constructor Details
#initialize(base: ChronoForge::Workflow.all, state: nil, job_class: nil, key: nil, created_from: nil, created_to: nil, before: nil, after: nil, per: DEFAULT_PER) ⇒ WorkflowsQuery
Returns a new instance of WorkflowsQuery.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/queries/chrono_forge/dashboard/workflows_query.rb', line 12 def initialize(base: ChronoForge::Workflow.all, state: nil, job_class: nil, key: nil, created_from: nil, created_to: nil, before: nil, after: nil, per: DEFAULT_PER) @base = base @state = state.presence @job_class = job_class.presence @key = key.presence @created_from = created_from.presence @created_to = created_to.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.
30 31 32 |
# File 'app/queries/chrono_forge/dashboard/workflows_query.rb', line 30 def per @per end |
Instance Method Details
#has_next? ⇒ Boolean
older rows remain
32 33 34 35 |
# File 'app/queries/chrono_forge/dashboard/workflows_query.rb', line 32 def has_next? # older rows remain load @has_next end |
#has_prev? ⇒ Boolean
newer rows remain
37 38 39 40 |
# File 'app/queries/chrono_forge/dashboard/workflows_query.rb', line 37 def has_prev? # newer rows remain load @has_prev end |
#next_cursor ⇒ Object
42 |
# File 'app/queries/chrono_forge/dashboard/workflows_query.rb', line 42 def next_cursor = records.last&.id |
#prev_cursor ⇒ Object
43 |
# File 'app/queries/chrono_forge/dashboard/workflows_query.rb', line 43 def prev_cursor = records.first&.id |
#records ⇒ Object
25 26 27 28 |
# File 'app/queries/chrono_forge/dashboard/workflows_query.rb', line 25 def records load @records end |