lib/rocket_job/active_worker.rb in rocketjob-3.4.3 vs lib/rocket_job/active_worker.rb in rocketjob-3.5.0

- old
+ new

@@ -2,11 +2,12 @@ # Information about a server currently working on a job class ActiveWorker # When this server started working on this job / slice attr_accessor :started_at - attr_accessor :name, :job + attr_accessor :job + attr_reader :name # Returns [Hash<String:ActiveWorker>] hash of all servers sorted by name # and what they are currently working on. # Returns {} if no servers are currently busy doing any work # @@ -14,11 +15,11 @@ # server_name: [String] # Only jobs running on the specified server def self.all(server_name = nil) servers = [] # Need paused, failed or aborted since servers may still be working on active slices - query = RocketJob::Job.where(:state.in => [:running, :paused, :failed, :aborted]) + query = RocketJob::Job.where(:state.in => %i[running paused failed aborted]) query = query.where(worker_name: /\A#{server_name}/) if server_name query.each do |job| servers += job.rocket_job_active_workers end servers @@ -48,10 +49,10 @@ Time.now - (started_at || Time.now) end # Returns [String] the name of the server running this worker def server_name - if match = name.to_s.match(/(.*:.*):.*/) + if (match = name.to_s.match(/(.*:.*):.*/)) match[1] else name end end