Class: Naf::MachineRunner
- Defined in:
- app/models/naf/machine_runner.rb
Class Method Summary collapse
- .dead_count ⇒ Object
-
.enabled ⇒ Object
———————- *** Class Methods *** ++++++++++++++++++++++.
- .running ⇒ Object
- .winding_down ⇒ Object
Instance Method Summary collapse
-
#current_invocation ⇒ Object
————————- *** Instance Methods *** +++++++++++++++++++++++++.
Methods inherited from NafBase
Class Method Details
.dead_count ⇒ Object
45 46 47 48 49 |
# File 'app/models/naf/machine_runner.rb', line 45 def self.dead_count (::Naf::MachineRunner.joins(:machine).where("#{::Naf.schema_name}.machines.enabled IS TRUE").pluck(:machine_id) - ::Naf::MachineRunner.running.pluck(:machine_id) - ::Naf::MachineRunner.winding_down.pluck(:machine_id)).uniq.count end |
.enabled ⇒ Object
*** Class Methods *** ++++++++++++++++++++++
28 29 30 31 |
# File 'app/models/naf/machine_runner.rb', line 28 def self.enabled joins(:machine). where("#{::Naf.schema_name}.machines.enabled IS TRUE") end |
.running ⇒ Object
33 34 35 36 37 |
# File 'app/models/naf/machine_runner.rb', line 33 def self.running joins(:machine_runner_invocations). where("#{::Naf.schema_name}.machine_runner_invocations.dead_at IS NULL AND #{::Naf.schema_name}.machine_runner_invocations.wind_down_at IS NULL") end |
.winding_down ⇒ Object
39 40 41 42 43 |
# File 'app/models/naf/machine_runner.rb', line 39 def self.winding_down joins(:machine_runner_invocations). where("#{::Naf.schema_name}.machine_runner_invocations.dead_at IS NULL AND #{::Naf.schema_name}.machine_runner_invocations.wind_down_at IS NOT NULL") end |
Instance Method Details
#current_invocation ⇒ Object
*** Instance Methods *** +++++++++++++++++++++++++
55 56 57 |
# File 'app/models/naf/machine_runner.rb', line 55 def current_invocation machine_runner_invocations.where(dead_at: nil, wind_down_at: nil).order(:id).last end |