From ca8283d47c8bd5ab65bd8e4978db4700288c019d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 17 Sep 2018 21:36:15 +0200 Subject: buildmaster/build-list.php: add filter options --- buildmaster/build-list.php | 166 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 153 insertions(+), 13 deletions(-) (limited to 'buildmaster') diff --git a/buildmaster/build-list.php b/buildmaster/build-list.php index 4b67cfc..34f058b 100644 --- a/buildmaster/build-list.php +++ b/buildmaster/build-list.php @@ -5,17 +5,82 @@ require_once BASE . "/lib/helper.php"; require_once BASE . "/lib/mysql.php"; require_once BASE . "/lib/style.php"; -if (isset($_GET["show"])) - $to_show=$_GET["show"]; +if (isset($_GET["q"])) + $filter = " WHERE `ba_q`.`pkgbase` LIKE from_base64(\"".base64_encode("%".$_GET["q"]."%")."\")"; else - $to_show="all"; + $filter = " WHERE 1"; -$to_shows = array( - "all" => "", - "broken" => " WHERE (`ba_q`.`is_broken` OR `ba_q`.`is_blocked` IS NOT NULL)", - "next" => " WHERE (`l_q`.`loops` IS NOT NULL OR (`rd_q`.`run_dependencies_pending` IS NULL AND `md_q`.`make_dependencies_pending` IS NULL))" +$multi_select_search_criteria = array( + "arch" => array( + "name" => "arch", + "title" => "CPU architecture", + "label" => "Arch", + "source_table" => "architectures", + "query_pre" => "`ba_q`.`arch` IN (", + "query_in_pre" => "\"", + "query_in_post" => "\",", + "query_post" => "\"\")", + "values" => array() + ), + "failures" => array( + "name" => "failures", + "title" => "Fail Reasons", + "label" => "Failures", + "source_table" => "fail_reasons", + "query_pre" => "(0", + "query_in_pre" => " OR `fr_q`.`fail_reasons_raw` LIKE \"%,", + "query_in_post" => ",%\"", + "query_post" => ")", + "values" => array() + ) ); +foreach ( $multi_select_search_criteria as $criterium => $content ) { + $result = mysql_run_query( + "SELECT `name` FROM `" . $content["source_table"] . "` ORDER BY `name`" + ); + while ($row = $result -> fetch_assoc()) + $multi_select_search_criteria[$criterium]["values"][] = $row["name"]; +} + +foreach ( $multi_select_search_criteria as $criterium ) { + if (isset($_GET[$criterium["name"]])) { + $filter .= " AND " . $criterium["query_pre"]; + foreach ($criterium["values"] as $value) + if (strpos("&" . $_SERVER["QUERY_STRING"] . "&", "&" . $criterium["name"] . "=" . $value . "&") !== false) + $filter .= $criterium["query_in_pre"] . $value . $criterium["query_in_post"]; + $filter .= $criterium["query_post"]; + } +} + +$single_select_search_criteria = array( + "broken" => array( + "name" => "broken", + "label" => "Is Broken", + "title" => "is broken", + "options" => array( + "All" => "1", + "Broken" => "(`ba_q`.`is_broken` OR `ba_q`.`is_blocked` IS NOT NULL)", + "Not Broken" => "NOT (`ba_q`.`is_broken` OR `ba_q`.`is_blocked` IS NOT NULL)" + ) + ), + "next" => array( + "name" => "next", + "label" => "Can Be Built", + "title" => "can be built", + "options" => array( + "All" => "1", + "Can" => "(`l_q`.`loops` IS NOT NULL OR (`rd_q`.`run_dependencies_pending` IS NULL AND `md_q`.`make_dependencies_pending` IS NULL))", + "Can't" => "NOT (`l_q`.`loops` IS NOT NULL OR (`rd_q`.`run_dependencies_pending` IS NULL AND `md_q`.`make_dependencies_pending` IS NULL))" + ) + ) +); + +foreach ($single_select_search_criteria as $criterium) + if (isset($_GET[$criterium["name"]]) && + isset($criterium["options"][$_GET[$criterium["name"]]])) + $filter .= " AND " . $criterium["options"][$_GET[$criterium["name"]]]; + $columns = array( "priority" => array( "label" => "Priority", @@ -132,7 +197,7 @@ $columns = array( "failure" => array( "label" => "Failures", "mysql_name" => "fail_reasons", - "mysql_query" => "`fr_q`.`fail_reasons`", + "mysql_query" => "`fr_q`.`fail_reasons_print`", "sort" => "failure", "title" => "reason of build failure" ), @@ -152,7 +217,6 @@ $columns = array( ) ); -$match = $to_shows[$to_show]; if (!isset($_GET["sort"])) $_GET["sort"]="trials"; @@ -261,7 +325,14 @@ $result = mysql_run_query( "\"\"" . ")" . " ORDER BY `fail_reasons`.`name`" . - ") AS `fail_reasons`" . + ") AS `fail_reasons_print`," . + "CONCAT(" . + "\",\"," . + "GROUP_CONCAT(" . + "`fail_reasons`.`name`" . + ")," . + "\",\"" . + ") AS `fail_reasons_raw`" . " FROM (" . "SELECT " . "`failed_builds`.`build_assignment`," . @@ -299,7 +370,7 @@ $result = mysql_run_query( " FROM `build_slaves`" . " GROUP BY `build_slaves`.`currently_building`" . ") AS `bs_q` ON `bs_q`.`currently_building`=`ba_q`.`id`" . - $match . + $filter . " ORDER BY " . $order . "`trials` " . $direction . ",`dependencies_pending` " . $direction . ",`is_blocked` " . $direction . ",`pkgbase` " . $direction ); @@ -329,9 +400,78 @@ while($row = $result->fetch_assoc()) { $count++; } -print_header("List of " . strtoupper(substr($to_show,0,1)) . substr($to_show,1) . " Package Builds"); +print_header("List of Package Builds"); -print "build logs\n"; +?> + build logs + \n"; +} + +?> +
+ + /> +
+\n"; + print " \n"; + print " \n"; +} +?> +
+ + +
+ + + + $dummy) { print "-\n"; -- cgit v1.2.3-70-g09d2