2013-11-08 21:14:04 +00:00
|
|
|
require 'ohm'
|
|
|
|
require 'ohm/expire'
|
|
|
|
|
|
|
|
class RpmBuildNode < Ohm::Model
|
|
|
|
include Ohm::Expire
|
|
|
|
|
|
|
|
TTL = 120
|
|
|
|
|
|
|
|
expire TTL
|
|
|
|
|
|
|
|
attribute :user_id
|
|
|
|
attribute :worker_count
|
|
|
|
attribute :busy_workers
|
|
|
|
attribute :system
|
|
|
|
|
|
|
|
def user
|
2014-01-21 04:51:49 +00:00
|
|
|
User.where(id: user_id).first
|
2013-11-08 21:14:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.total_statistics
|
|
|
|
systems, others, busy = 0, 0, 0
|
|
|
|
RpmBuildNode.all.select{ |n| n.user_id }.each do |n|
|
|
|
|
if n.system == 'true'
|
|
|
|
systems += n.worker_count.to_i
|
|
|
|
else
|
|
|
|
others += n.worker_count.to_i
|
|
|
|
end
|
|
|
|
busy += n.busy_workers.to_i
|
|
|
|
end
|
2014-01-21 04:51:49 +00:00
|
|
|
{ systems: systems, others: others, busy: busy }
|
2013-11-08 21:14:04 +00:00
|
|
|
end
|
2014-03-11 07:39:25 +00:00
|
|
|
end
|