rosa-build/app/presenters/abf_worker_status_presenter.rb

25 lines
754 B
Ruby
Raw Normal View History

2016-03-20 09:24:23 +00:00
class AbfWorkerStatusPresenter
def initialize
end
def projects_status
2016-06-15 01:17:42 +01:00
Rails.cache.fetch([AbfWorkerStatusPresenter, :projects_status], expires_in: 30.seconds) do
result = {rpm: {}}
nodes = RpmBuildNode.total_statistics
2016-06-15 01:17:42 +01:00
result[:rpm][:workers] = nodes[:systems]
result[:rpm][:build_tasks] = nodes[:busy]
result[:rpm][:other_workers] = nodes[:others]
2016-06-15 01:17:42 +01:00
normal_pending = BuildList.for_status(BuildList::BUILD_PENDING).where(mass_build_id: nil).count
mass_build_pending = BuildList.for_status(BuildList::BUILD_PENDING).where.not(mass_build_id: nil).count
result[:rpm][:pending] = normal_pending
result[:rpm][:mass_build_pending] = mass_build_pending
result
end
end
end