10 grab_statistics: function(data, jobstates) {
11 this.jobs = data.jobs;
12 this.clients = data.clients;
13 this.pools = data.pools;
14 this.jobtotals = data.jobtotals;
15 this.dbsize = data.dbsize;
16 var jobs_count = this.jobs.length;
17 var clients_occupancy = {};
18 var pools_occupancy = {};
19 var jobs_occupancy = {};
28 for (var i = 0; i < jobs_count; i++) {
29 if (typeof(clients_occupancy[this.jobs[i].clientid]) === 'undefined') {
30 clients_occupancy[this.jobs[i].clientid] = 1;
32 clients_occupancy[this.jobs[i].clientid] += 1;
35 if (typeof(pools_occupancy[this.jobs[i].poolid]) === 'undefined') {
36 pools_occupancy[this.jobs[i].poolid] = 1;
38 pools_occupancy[this.jobs[i].poolid] += 1;
41 if (typeof(jobs_occupancy[this.jobs[i].name]) === 'undefined') {
42 jobs_occupancy[this.jobs[i].name] = 1;
44 jobs_occupancy[this.jobs[i].name] += 1;
46 if (jobstates.hasOwnProperty(this.jobs[i].jobstatus)) {
47 status_type = jobstates[this.jobs[i].jobstatus].type;
48 if (status_type == 'ok' && this.jobs[i].joberrors > 0) {
49 status_type = 'warning';
51 jobs_summary[status_type].push(this.jobs[i]);
54 var clients_ids = Object.keys(clients_occupancy);
55 for (var i = 0; i < clients_ids.length; i++) {
56 for (var j = 0; j < this.clients.length; j++) {
57 if (clients_ids[i] == this.clients[j].clientid) {
58 this.clients_occupancy[this.clients[j].name] = clients_occupancy[clients_ids[i]];
63 var pools_ids = Object.keys(pools_occupancy);
64 for (var i = 0; i < pools_ids.length; i++) {
65 for (var j = 0; j < this.pools.length; j++) {
66 if (pools_ids[i] == this.pools[j].poolid) {
67 this.pools_occupancy[this.pools[j].name] = pools_occupancy[pools_ids[i]];
72 this.jobs_occupancy = jobs_occupancy;
73 this.jobs_summary = jobs_summary;