Readd status panel

This commit is contained in:
Wedge 2016-06-15 03:17:42 +03:00
parent 74313e2369
commit 8cbe33ab0a
9 changed files with 36 additions and 82 deletions

View File

@ -68,6 +68,7 @@ function($scope, BuildListsService, $location, $interval, $uibModal) {
$scope.total_items = res.total_items;
$location.search(Object.assign(filter, res.filter));
$scope.per_page = filter.per_page;
$scope.server_status = res.server_status;
$scope.isRequest = false;
});
}
@ -138,7 +139,6 @@ function($scope, BuildListsService, $location, $interval, $uibModal) {
RosaABF.controller('FiltersInstanceController', ['$scope', '$uibModalInstance', 'params',
function($scope, $uibModalInstance, params) {
console.log(params);
$scope.params = params;
$scope.apply = function() {

View File

@ -65,7 +65,7 @@ RosaABF.controller 'StatisticsController', ['$scope', '$http', '$timeout', ($sco
range_end: $scope.range_end
users_or_groups: $scope.users_or_groups
format: 'json'
console.log($scope.users_or_groups)
$http.get($scope.statistics_path, params: params).success (results) ->
$scope.statistics = results

View File

@ -37,7 +37,6 @@ var BuildList = function(atts, dictionary) {
self.version_link_url = Routes.commit_path(self.project.name_with_owner, self.version_link_text);
}
self.project.url = Routes.project_build_lists_path(self.project.name_with_owner);
console.log(self.project.url);
}
if (self.user)

View File

@ -68,7 +68,8 @@ angular.module("RosaABF").factory('BuildListsService', ["$http", function($http)
build_lists: build_lists_final,
page: results.data.page,
total_items: results.data.total_items,
filter: results.data.filter
filter: results.data.filter,
server_status: results.data.server_status
};
});
}

View File

@ -35,7 +35,7 @@ class Projects::BuildListsController < Projects::BaseController
:source_packages,
project: :project_statistics)
#@build_server_status = AbfWorkerStatusPresenter.new.projects_status
@build_server_status = AbfWorkerStatusPresenter.new.projects_status
end
end
end

View File

@ -69,7 +69,7 @@ class Projects::ProjectsController < Projects::BaseController
if @project.save
flash[:notice] = t('flash.project.saved')
redirect_to @project
redirect_to project_build_lists_path(@project)
else
flash[:error] = t('flash.project.save_error')
flash[:warning] = @project.errors.full_messages.join('. ')

View File

@ -4,56 +4,21 @@ class AbfWorkerStatusPresenter
end
def projects_status
Rails.cache.fetch([AbfWorkerStatusPresenter, :projects_status], expires_in: 10.seconds) do
result = get_status(:rpm, :publish) { |w, worker| w.to_s =~ /#{worker}_worker_default/ }
Rails.cache.fetch([AbfWorkerStatusPresenter, :projects_status], expires_in: 30.seconds) do
result = {rpm: {}}
nodes = RpmBuildNode.total_statistics
result[:rpm][:workers] += nodes[:systems]
result[:rpm][:build_tasks] += nodes[:busy]
result[:rpm][:workers] = nodes[:systems]
result[:rpm][:build_tasks] = nodes[:busy]
result[:rpm][:other_workers] = nodes[:others]
external_bls = BuildList.for_status(BuildList::BUILD_PENDING).external_nodes(:everything).count
result[:rpm][:default_tasks] += external_bls + count_of_tasks('user_build_')
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
mass_build_tasks = count_of_tasks('mass_build_')
result[:rpm][:low_tasks] += mass_build_tasks
result[:rpm][:tasks] += external_bls + mass_build_tasks
result
end
end
def products_status
get_status(:iso) { |w, worker|
str = w.to_s
str =~ /iso_worker/ && str !~ /observer/
}
end
protected
def count_of_tasks(regexp)
Redis.current.smembers('resque:queues').
select{ |q| q =~ /#{regexp}/ }.
map{ |q| Redis.current.llen("resque:queue:#{q}") }.sum
end
def get_status(*queues)
status = {}
#queues.each do |worker|
# workers = Resque.workers.select{ |w| yield w, worker }
# status[worker] = status_of_worker workers, worker
#end
status
end
def status_of_worker(workers, worker)
key = "resque:queue:#{worker}_worker"
default_tasks, tasks = Redis.current.llen("#{key}_default"), Redis.current.llen(key)
{
workers: workers.count,
build_tasks: workers.select{ |w| w.working? }.count,
default_tasks: default_tasks,
low_tasks: tasks,
tasks: (default_tasks + tasks)
}
end
end

View File

@ -1,32 +1,20 @@
ul.nav.navbar-nav.navbar-left
li.bg-success
a.no-pointer href=''
i.fa.fa-info-circle.fa-lg.text-primary
=< t 'layout.build_lists.build_server_status.rpm_workers'
' :
=> t 'layout.build_lists.build_server_status.abf'
span.badge.bg-primary[] {{server_status.rpm.workers}}
.well.well-sm
= t('layout.build_lists.build_server_status.rpm_workers')
| :
=> t('layout.build_lists.build_server_status.abf')
span.badge
| {{::server_status.rpm.workers}}
=<> t 'layout.build_lists.build_server_status.custom'
span.badge.bg-primary[] {{server_status.rpm.other_workers}}
li.bg-info
a.no-pointer href=''
= t('layout.build_lists.build_server_status.tasks').mb_chars.capitalize
' :
=> t 'layout.build_lists.build_server_status.custom'
span.badge.bg-primary[] {{server_status.rpm.default_tasks}}
span.badge
| {{::server_status.rpm.other_workers}}
=< t('layout.build_lists.build_server_status.tasks').mb_chars.capitalize
| :
=<> t('layout.build_lists.build_server_status.custom')
span.badge
| {{::server_status.rpm.pending}}
=<> t 'layout.build_lists.build_server_status.mass_build_tasks'
span.badge.bg-primary[] {{server_status.rpm.low_tasks}}
=<> t 'layout.build_lists.build_server_status.build_tasks'
span.badge.bg-primary[] {{server_status.rpm.build_tasks}}
li.bg-warning
a.no-pointer href=''
= t 'layout.build_lists.build_server_status.publish_workers'
' :
=> t 'layout.build_lists.build_server_status.amount'
span.badge.bg-primary[] {{server_status.publish.workers}}
=<> t 'layout.build_lists.build_server_status.tasks'
span.badge.bg-primary[] {{server_status.publish.tasks}}
=<> t 'layout.build_lists.build_server_status.build_tasks'
span.badge.bg-primary[] {{server_status.publish.build_tasks}}
span.badge
| {{::server_status.rpm.mass_build_pending}}
=<> t('layout.build_lists.build_server_status.build_tasks')
span.badge
| {{::server_status.rpm.build_tasks}}

View File

@ -1,5 +1,6 @@
.row.top-space
.col-md-12 ng-controller="BuildListsController" ng-init=('getBuildLists("'+params[:name_with_owner].to_s+'")')
== render 'projects/build_lists/server_status'
== render 'projects/build_lists/filter'
rd-widget
rd-widget-header title="Build Lists {{::widgetTitle}}" icon="fa-gears"