aboutsummaryrefslogtreecommitdiffstats
path: root/Report/Box/03_BuildSystem.php
blob: b2d020d8b0791122344d11857d23ca9cce4a842f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
 * Buildsystem reporting box.
 *
 * PHP version 5
 *
 * @category Dashboard
 * @package  Buildsystem
 * @author   Romain d'Alverny <rda@mageia.org>
 * @license  MIT License, see LICENSE.txt
 * @link     http://svnweb.mageia.org/svn/soft/dashboard/
*/
/**
*/
class Report_Box_PackageBuildSystem extends Report_Box
{
    /**
    */
    var $title = "Packages Build <span class=\"light\">(past 48 hours)</span>";
    
    /**
    */
    function _get_var_definitions() {
        return array(
            'x_bs_queue_uploaded' => ':render', //'%d packages uploaded',
            'x_bs_queue_failure'  => array('l' => '%d failed to build', 't' => '==0', 'w' => 0),
            'x_bs_queue_rejected' => array('l' => '%d rejected', 't' => '==0', 'w' => 0),
            'x_bs_buildtime' => ':render',
            'x_bs_buildtime_average' => ':render',
            'nodes' => ':render',
            'queue_size_avg' => 'queue size: 4/0/20',
            'wait_time' => 'wait time: 5/2/45'
        );
    }
    /*
    missing dependencies %
    other
    */
    
    function _render_value_x_bs_buildtime()
    {
        return array(
            't' => sprintf('%5.2f hours of total buildtime<br />(%d%% of the time)',
                $this->_cur_val / 60, 
                $this->_cur_val / 60 / 48 * 100
            ),
            'c' => 'ok',
            's' => 0
        );
    }
    
    function _render_value_x_bs_buildtime_average()
    {
        return array(
            't' => sprintf('%5.2f min of average buildtime', $this->_cur_val),
            'c' => 'ok',
            's' => 0
        );
    }
    
    function _render_value_nodes()
    {
        return array(
            't' => '? nodes working fine out of ?',
            'c' => 'unk',
            's' => 0
        );
    }
    
    function _render_value_x_bs_queue_uploaded()
    {
        return array(
            't' => sprintf('%d packages uploaded', $this->_cur_val),
            'c' => 'ok',
            's' => 0
        );
    }

    /**
    */
    function _get_links()
    {
        return 'View <a href="http://pkgsubmit.mageia.org/">pkgsubmit</a>';
    }

    /**
     * Fetch live report values from pkgsubmit HTTP headers,
     * prefixed with X-BS-
     *
     * @return array
    */
    function _fetch_buildsystem()
    {
        $ret = array();
        $h = get_headers('http://pkgsubmit.mageia.org/');
        foreach ($h as $v)
        {
            $v = explode(':', trim($v));
            if (substr($v[0], 0, 5) == 'X-BS-')
            {
                $k = str_replace('-', '_', strtolower($v[0]));
                if (in_array($k, array(
                        'x_bs_queue_todo',
                        'x_bs_queue_building',
                        'x_bs_queue_partial',
                        'x_bs_queue_built',
                        'x_bs_throttle'
                    )))
                    continue;
                $ret[$k] = trim($v[1]);
            }
        }
        return $ret;
    }
}