Class: ChronoForge::Dashboard::StatsQuery
- Inherits:
-
Object
- Object
- ChronoForge::Dashboard::StatsQuery
- Defined in:
- app/queries/chrono_forge/dashboard/stats_query.rb
Overview
Per-state workflow counts, each capped so the panel never pays for an unbounded COUNT. Each count is an index-only COUNT over a ‘LIMIT CAP` subquery on the (state, …) index, so it costs O(CAP) regardless of how many rows match; a saturated count renders as “CAP+”.
Constant Summary collapse
- CAP =
5000
Instance Attribute Summary collapse
-
#cap ⇒ Object
readonly
Returns the value of attribute cap.
Instance Method Summary collapse
- #counts ⇒ Object
-
#initialize(base: ChronoForge::Workflow.all, cap: CAP) ⇒ StatsQuery
constructor
A new instance of StatsQuery.
Constructor Details
#initialize(base: ChronoForge::Workflow.all, cap: CAP) ⇒ StatsQuery
Returns a new instance of StatsQuery.
10 11 12 13 |
# File 'app/queries/chrono_forge/dashboard/stats_query.rb', line 10 def initialize(base: ChronoForge::Workflow.all, cap: CAP) @base = base @cap = cap end |
Instance Attribute Details
#cap ⇒ Object (readonly)
Returns the value of attribute cap.
15 16 17 |
# File 'app/queries/chrono_forge/dashboard/stats_query.rb', line 15 def cap @cap end |
Instance Method Details
#counts ⇒ Object
17 18 19 20 21 |
# File 'app/queries/chrono_forge/dashboard/stats_query.rb', line 17 def counts ChronoForge::Workflow.states.keys.index_with do |name| capped(@base.where(state: ChronoForge::Workflow.states[name])) end end |