Class: ChronoForge::Dashboard::OverviewQuery

Inherits:
Object
  • Object
show all
Defined in:
app/queries/chrono_forge/dashboard/overview_query.rb

Overview

Fleet-wide throughput: how much each workflow class has processed, plus its current in-flight and blocked load. One GROUP BY (job_class, state) scan feeds the whole page — the honest cost of a "totals across everything" view (a total can't be capped the way StatsQuery caps the hot workflow list).

Defined Under Namespace

Classes: Row

Constant Summary collapse

IN_FLIGHT =
%i[idle running].map { |s| ChronoForge::Workflow.states[s] }.freeze
BLOCKED =
%i[failed stalled].map { |s| ChronoForge::Workflow.states[s] }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.blocked_totalObject



23
# File 'app/queries/chrono_forge/dashboard/overview_query.rb', line 23

def self.blocked_total = ChronoForge::Workflow.where(state: BLOCKED).count

.in_flight_totalObject



21
# File 'app/queries/chrono_forge/dashboard/overview_query.rb', line 21

def self.in_flight_total = ChronoForge::Workflow.where(state: IN_FLIGHT).count

.processed_totalObject

Fleet-wide card totals — each an independent COUNT so its turbo-frame can load without paying for the per-class GROUP BY the table frame runs.



19
# File 'app/queries/chrono_forge/dashboard/overview_query.rb', line 19

def self.processed_total = ChronoForge::Workflow.completed.count

Instance Method Details

#rowsObject



25
26
27
# File 'app/queries/chrono_forge/dashboard/overview_query.rb', line 25

def rows
  @rows ||= build_rows
end

#totalsObject

Synthetic bottom row summing every class.



30
31
32
33
34
35
36
37
# File 'app/queries/chrono_forge/dashboard/overview_query.rb', line 30

def totals
  @totals ||= Row.new(
    job_class: nil,
    processed: rows.sum(&:processed),
    in_flight: rows.sum(&:in_flight),
    blocked: rows.sum(&:blocked)
  )
end