Class: Naf::RunningJob
Class Method Summary collapse
- .affinity_weights(machine) ⇒ Object
- .assigned_jobs(machine) ⇒ Object
- .in_run_group(run_group_name) ⇒ Object
-
.started_on(machine) ⇒ Object
————————- *** Class Methods *** +++++++++++++++++++++++++.
- .started_on_invocation(invocation_id) ⇒ Object
Instance Method Summary collapse
-
#add_tags(tags_to_add) ⇒ Object
————————- *** Instance Methods *** +++++++++++++++++++++++++.
- #remove_all_tags ⇒ Object
- #remove_tags(tags_to_remove) ⇒ Object
Methods inherited from NafBase
Class Method Details
.affinity_weights(machine) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/models/naf/running_job.rb', line 68 def self.affinity_weights(machine) affinity_ids = ::Naf::Affinity.all.map(&:id) job_weights = {} affinity_ids.each do |affinity_id| job_weights[affinity_id] = 0 end ::Naf::RunningJob.where(started_on_machine_id: machine.id).all.each do |running_job| affinity_ids.each do |affinity_id| job_weights[affinity_id] += running_job. historical_job.historical_job_affinity_tabs. where(affinity_id: affinity_id). first.try(:affinity_parameter).to_f end end job_weights end |
.assigned_jobs(machine) ⇒ Object
64 65 66 |
# File 'app/models/naf/running_job.rb', line 64 def self.assigned_jobs(machine) started_on(machine) end |
.in_run_group(run_group_name) ⇒ Object
60 61 62 |
# File 'app/models/naf/running_job.rb', line 60 def self.in_run_group(run_group_name) where(application_run_group_name: run_group_name) end |
.started_on(machine) ⇒ Object
*** Class Methods *** +++++++++++++++++++++++++
51 52 53 |
# File 'app/models/naf/running_job.rb', line 51 def self.started_on(machine) where(started_on_machine_id: machine.id) end |
.started_on_invocation(invocation_id) ⇒ Object
55 56 57 58 |
# File 'app/models/naf/running_job.rb', line 55 def self.started_on_invocation(invocation_id) joins(:historical_job). where("#{::Naf.schema_name}.historical_jobs.machine_runner_invocation_id = #{invocation_id}") end |
Instance Method Details
#add_tags(tags_to_add) ⇒ Object
*** Instance Methods *** +++++++++++++++++++++++++
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/models/naf/running_job.rb', line 92 def () = nil if self..present? = self..gsub(/[{}]/,'').split(',') = '{' + ( | ).join(',') + '}' else = '{' + .join(',') + '}' end self. = self.save! end |
#remove_all_tags ⇒ Object
115 116 117 118 |
# File 'app/models/naf/running_job.rb', line 115 def self. = '{}' self.save! end |
#remove_tags(tags_to_remove) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'app/models/naf/running_job.rb', line 105 def () if self..present? = self..gsub(/[{}]/,'').split(',') = '{' + ( - ).join(',') + '}' self. = self.save! end end |