// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
require_once "../inc/util_ops.inc";
db_init();
admin_page_head("Failures grouped by app version and host");
$query_appid = $_GET['appid'];
$query_received_time = time() - $_GET['nsecs'];
$main_query = "\nSELECT\n       app_version_id,\n       app_version_num,\n       hostid AS Host_ID,\n       case\n           when INSTR(host.os_name, 'Darwin') then 'Darwin'\n           when INSTR(host.os_name, 'Linux') then 'Linux'\n           when INSTR(host.os_name, 'Windows') then 'Windows'\n           when INSTR(host.os_name, 'SunOS') then 'SunOS'\n           when INSTR(host.os_name, 'Solaris') then 'Solaris'\n           when INSTR(host.os_name, 'Mac') then 'Mac'\n           else 'Unknown'\n       end AS OS_Name,\n       case\n           when INSTR(host.os_name, 'Linux') then \n               case\n                   when INSTR(LEFT(host.os_version, 6), '-') then LEFT(host.os_version, (INSTR(LEFT(host.os_version, 6), '-') - 1))\n                   else LEFT(host.os_version, 6)\n               end\n           else host.os_version\n       end AS OS_Version,\n       host.nresults_today AS Results_Today, \n       COUNT(*) AS error_count\nFROM   result\n           left join host on result.hostid = host.id \nWHERE\n       appid = '{$query_appid}' and\n       server_state = '5' and\n       outcome = '3' and \n       received_time > '{$query_received_time}'\nGROUP BY\n       app_version_id,\n       hostid\norder by error_count desc\n";
$result = _mysql_query($main_query);
start_table();
table_header("App version", "Host ID", "OS Version", "Results today", "Error count");
while ($res = _mysql_fetch_object($result)) {
    table_row(app_version_desc($res->app_version_id), "<a href=" . URL_BASE . "show_host_detail.php?hostid={$res->Host_ID}>{$res->Host_ID}</a>", $res->OS_Version, $res->Results_Today, "<a href=db_action.php?table=result&detail=low&hostid={$res->Host_ID}&app_version_id={$res->app_version_id}&server_state=5&outcome=3>{$res->error_count}</a>");
}
_mysql_free_result($result);
end_table();
admin_page_tail();
$cvs_version_tracker[] = "\$Id\$";
//Generated automatically - do not edit
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
require_once "../inc/util_ops.inc";
db_init();
admin_page_head("Failure summary by (app version, error)");
$query_appid = $_GET['appid'];
$query_received_time = time() - $_GET['nsecs'];
$q = new SqlQueryString();
$q->process_form_items();
$main_query = "\nSELECT\n    app_version_id,\n    app_version.plan_class,\n    case\n        when INSTR(host.os_name, 'Darwin') then 'Darwin'\n        when INSTR(host.os_name, 'Linux') then 'Linux'\n        when INSTR(host.os_name, 'Windows') then 'Windows'\n        when INSTR(host.os_name, 'SunOS') then 'SunOS'\n        when INSTR(host.os_name, 'Solaris') then 'Solaris'\n        when INSTR(host.os_name, 'Mac') then 'Mac'\n        else 'Unknown'\n    end AS OS_Name,\n    exit_status,\n    COUNT(*) AS error_count\nFROM   result\n        left join host on result.hostid = host.id\n        left join app_version on result.app_version_id = app_version.id\nWHERE\n    result.appid = '{$query_appid}' and\n    server_state = '5' and\n    outcome = '3' and\n    received_time > '{$query_received_time}'\nGROUP BY\n    app_version_id,\n    exit_status\norder by error_count desc\n";
$urlquery = $q->urlquery;
$result = _mysql_query($main_query);
start_table();
table_header("App version", "Exit Status", "Error Count");
while ($res = _mysql_fetch_object($result)) {
    $exit_status_condition = "exit_status={$res->exit_status}";
    table_row(app_version_desc($res->app_version_id), link_results(exit_status_string($res->exit_status), $urlquery, "{$exit_status_condition}", ""), $res->error_count);
}
_mysql_free_result($result);
end_table();
admin_page_tail();
$cvs_version_tracker[] = "\$Id\$";
//Generated automatically - do not edit