array( "label" => "name", "mysql_name" => "name", "mysql_query" => "`build_slaves`.`name`", "sort" => "name", "title" => "name" ), "operator" => array( "label" => "operator", "mysql_name" => "operator", "mysql_query" => "`persons`.`name`", "sort" => "operator", "title" => "operator" ), "currently_building" => array( "label" => "currently building", "mysql_name" => "cb", "mysql_query" => "`ba_q`.`cb`", "mysql_ba_q_name" => "cb", "mysql_ba_q_query" => "CONCAT(`architectures`.`name`,\"/\",`package_sources`.`pkgbase`)", "sort" => "currently_building", "title" => "pkgbase of currently building package" ), "last_connection" => array( "label" => "last connection", "mysql_name" => "lc", "mysql_query" => "`sl_q`.`lc`", "mysql_sl_q_name" => "lc", "mysql_sl_q_query" => "MAX(`ssh_log`.`date`)", "sort" => "last_connection", "title" => "time of last connection" ), "building_since" => array( "label" => "building since", "mysql_name" => "bs", "mysql_query" => "`sl_q`.`bs`", "mysql_sl_q_name" => "bs", "mysql_sl_q_query" => "MAX(IF(`ssh_log`.`action`=\"get-assignment\",`ssh_log`.`date`,NULL))", "sort" => "building_since", "title" => "start of build" ), "trials" => array( "label" => "trials", "mysql_name" => "trials", "mysql_query" => "`build_slaves`.`trials`", "sort" => "trials", "title" => "number of trials" ), "logged_lines" => array( "label" => "logged lines", "mysql_name" => "ll", "mysql_query" => "`build_slaves`.`logged_lines`", "sort" => "logged_lines", "title" => "number of logged lines so far" ), "last_action" => array( "label" => "last action", "mysql_name" => "la", "mysql_query" => "`build_slaves`.`last_action`", "sort" => "last_action", "title" => "last action" ) ); if (!isset($_GET["sort"])) $_GET["sort"]="-last_connection"; if (substr($_GET["sort"],0,1) == "-") { $direction = " DESC"; $sort = substr($_GET["sort"],1); } else { $direction = " ASC"; $sort = $_GET["sort"]; } if (isset($columns[$sort])) $order = "IFNULL(`sub_query`.`" . $columns[$sort]["mysql_name"] . "`,0) " . $direction . ","; else $order = ""; function combine_fields($cln) { return $cln["mysql_query"] . " AS `" . $cln["mysql_name"] . "`"; } function combine_ba_q_fields($cln) { if (isset($cln["mysql_ba_q_query"]) && isset($cln["mysql_ba_q_name"])) return $cln["mysql_ba_q_query"] . " AS `" . $cln["mysql_ba_q_name"] . "`"; } function combine_sl_q_fields($cln) { if (isset($cln["mysql_sl_q_query"]) && isset($cln["mysql_sl_q_name"])) return $cln["mysql_sl_q_query"] . " AS `" . $cln["mysql_sl_q_name"] . "`"; } function non_empty($val) { return ! empty($val); } $result = mysql_run_query( "SELECT `sub_query`.* FROM (" . "SELECT " . implode(",",array_map("combine_fields",$columns)) . " FROM `build_slaves`" . " JOIN `ssh_keys`" . " ON `build_slaves`.`ssh_key`=`ssh_keys`.`id`" . " JOIN `persons`" . " ON `ssh_keys`.`owner`=`persons`.`id`" . " LEFT JOIN (" . "SELECT " . "`build_assignments`.`id` AS `id`," . implode(",",array_filter(array_map("combine_ba_q_fields",$columns),"non_empty")) . " FROM `build_assignments`" . " JOIN `package_sources`" . " ON `build_assignments`.`package_source`=`package_sources`.`id`" . " JOIN `architectures`" . " ON `build_assignments`.`architecture`=`architectures`.`id`" . ") AS `ba_q`" . " ON `ba_q`.`id`=`build_slaves`.`currently_building`" . " LEFT JOIN (" . "SELECT " . "`ssh_log`.`build_slave` AS `build_slave`," . implode(",",array_filter(array_map("combine_sl_q_fields",$columns),"non_empty")) . " FROM `ssh_log`" . " WHERE `ssh_log`.`date`>=ADDDATE(NOW(),\"-5 00:00:00\")" . " GROUP BY `ssh_log`.`build_slave`" . ") AS `sl_q`" . " ON `sl_q`.`build_slave`=`build_slaves`.`id`" . ") AS `sub_query`" . " ORDER BY " . $order . "`sub_query`.`name`" ); $count = 0; while($row = $result->fetch_assoc()) { foreach ($row as $name => $value) { if (!isset($row[$name])) $rows[$count][$name] = " "; else $rows[$count][$name] = $value; } $rows[$count]["name"] = "" . $row["name"] . ""; $count++; } print_header("List of Build Slaves"); if ($count > 0) { ?>
\n"; print " " . $row[$column["mysql_name"]] . "\n"; print " | \n"; } print " \n"; if ($oddity == "odd" ) $oddity = "even"; else $oddity = "odd"; } ?>