.
require_once("../inc/common_defs.inc");
require_once("../inc/util_ops.inc");
require_once("../inc/cache.inc");
// User - configuarble variables
// seconds to cache this page
// this page runs a scan of the two largest tables, so this shouldn't be done more often than necessary
$cache_sec = 1800;
// Number that determines how many client errors are necessary for a WU to show up in this list.
// This number is added to min_quorum of the WU, so a value of 1 means that there must be more than
// (min_quorum + 1) errors for a WU to show up in this list.
$notification_level = get_int("level", true);
if (!$notification_level) {
$notification_level = 1;
}
$appid_filter = "";
$appid_title = "";
$appid = get_int("appid", true);
if ($appid) {
$appid_filter = " appid = $appid AND ";
$app = BoincApp::lookup_id($appid);
$appid_title = " for ".$app->name;
}
// the following variables are using the cache that is created by the variables above
// hide already canceled WUs
$hide_canceled = get_str("hide_canceled", true);
// hide WU that have only download errors
$hide_dlerr = get_str("hide_dlerr", true);
// refresh cache from DB
$refresh_cache = get_int("refresh_cache", true);
admin_page_head("All-error Workunits".$appid_title);
function print_wu($row) {
echo "
\n";
}
function get_error_wus() {
global $notification_level;
global $appid_filter;
// this query is obviously expensive for big projects but if there is a replica this does not impact the project
$db = BoincDb::get(true);
$dbresult = $db->do_query("
SELECT id, name, appid, unsent, in_progress, successes, compute_errors,
download_errors, validate_errors, error_mask, min_quorum,
(compute_errors + download_errors + validate_errors) as total_errors
FROM (
SELECT
workunitid,
SUM(IF(outcome=1,1,0)) AS successes,
SUM(IF((outcome=3 AND client_state=1),1,0)) AS download_errors,
SUM(IF((outcome=3 AND client_state=3),1,0)) AS compute_errors,
SUM(IF(outcome=6,1,0)) AS validate_errors,
SUM(IF(server_state=2,1,0)) AS unsent,
SUM(IF(server_state=4,1,0)) AS in_progress
FROM result
WHERE server_state IN (2,4,5)
GROUP BY workunitid
) AS t1
JOIN workunit ON workunit.id = workunitid
WHERE canonical_resultid=0 AND $appid_filter
GREATEST(download_errors, compute_errors, validate_errors) > min_quorum + $notification_level
ORDER BY name
;");
$row_cache = array();
while ($row = $dbresult->fetch_object()) {
$row_cache[] = $row;
}
$dbresult->free();
return $row_cache;
}
$last_update = 0;
$row_array = null;
$cache_args = "level=$notification_level";
if ($appid) $cache_args .= "&appid=$appid";
$cache_data = get_cached_data($cache_sec, $cache_args);
if ($cache_data && !$refresh_cache) {
$cache_data = unserialize($cache_data);
$last_update = $cache_data['last_update'];
$row_array = $cache_data['row_array'];
} else {
$row_array = get_error_wus();
$last_update = time();
$cache_data = array('last_update' => $last_update, 'row_array' => $row_array);
set_cached_data($cache_sec, serialize($cache_data), $cache_args);
}
echo " ";
echo "\n";
echo "Page last updated ".time_str($last_update);
if (!in_rops()) {
echo "\n";
}
echo count($row_array)." entries (".$hidden." hidden)\n";
admin_page_tail();
?>