mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=1984
This commit is contained in:
parent
341a5189d9
commit
b3405d045f
|
@ -1,85 +1,19 @@
|
|||
<?php
|
||||
<?php {
|
||||
require_once("util_ops.inc");
|
||||
require_once("db_ops.inc");
|
||||
|
||||
function append_sql_query($original,$addition,$first) {
|
||||
function append_sql_query($original,$addition,$first) {
|
||||
if ($first == 1) {
|
||||
return $original . " where " . $addition;
|
||||
} else {
|
||||
return $original . " and " . $addition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db_init();
|
||||
|
||||
parse_str(getenv("QUERY_STRING"));
|
||||
|
||||
$first = 1;
|
||||
|
||||
if (strlen($clauses)) {
|
||||
$query = append_sql_query( $query, $clauses, $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($id)) {
|
||||
$query = append_sql_query( $query, "id = $id", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($plat_id)) {
|
||||
$query = append_sql_query( $query, "platformid = $plat_id", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($app_id)) {
|
||||
$query = append_sql_query( $query, "appid = $app_id", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($wu_id)) {
|
||||
$query = append_sql_query( $query, "workunitid = $wu_id", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($hostid)) {
|
||||
$query = append_sql_query( $query, "hostid = $hostid", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($userid)) {
|
||||
$query = append_sql_query( $query, "userid = $userid", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($team_id)) {
|
||||
$query = append_sql_query( $query, "teamid = $team_id", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($received_time)) {
|
||||
$query = append_sql_query( $query, "received_time > $received_time", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($result_server_state) && $result_server_state>0) {
|
||||
$query = append_sql_query( $query, "server_state = $result_server_state", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($result_outcome) && $result_outcome>0) {
|
||||
$query = append_sql_query( $query, "outcome = $result_outcome", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($result_client_state) && $result_client_state>0) {
|
||||
$query = append_sql_query( $query, "client_state = $result_client_state", $first );
|
||||
$first = 0;
|
||||
}
|
||||
|
||||
if (strlen($sort_by)) {
|
||||
$query = $query . " order by $sort_by desc";
|
||||
$first = 0;
|
||||
}
|
||||
$q = build_sql_query($table);
|
||||
|
||||
if (strlen($nresults)) {
|
||||
$entries_to_show = $nresults;
|
||||
|
@ -95,11 +29,7 @@ function append_sql_query($original,$addition,$first) {
|
|||
|
||||
page_head($table);
|
||||
|
||||
|
||||
$count_query = "select count(*) as cnt from ".$table." ".$query;
|
||||
$result = mysql_query($count_query);
|
||||
$res = mysql_fetch_object($result);
|
||||
$count = $res->cnt;
|
||||
$count = $q->count();
|
||||
|
||||
if ($count < $start_at + $entries_to_show) {
|
||||
$entries_to_show = $count - $start_at;
|
||||
|
@ -107,11 +37,7 @@ function append_sql_query($original,$addition,$first) {
|
|||
|
||||
$last = $start_at + $entries_to_show;
|
||||
|
||||
if ($start_at) {
|
||||
$main_query = "select * from ".$table." ".$query. " limit ".$start_at.",".$entries_to_show;
|
||||
} else {
|
||||
$main_query = "select * from ".$table." ".$query. " limit ".$entries_to_show;
|
||||
}
|
||||
$main_query = $q->get_select_query($entries_to_show, $start_at);
|
||||
|
||||
echo "<p>Query: <b>$main_query</b><p>\n";
|
||||
echo "
|
||||
|
@ -119,11 +45,13 @@ function append_sql_query($original,$addition,$first) {
|
|||
Displaying $start_at to $last.<p>
|
||||
";
|
||||
|
||||
$urlquery = urlencode($query);
|
||||
$urlquery = urlencode($q->query);
|
||||
if ($last < $count) {
|
||||
echo "
|
||||
<a href=db_action.php?table=$table&query=$urlquery&last_pos=$last&detail=$detail>Next $entries_to_show</a>
|
||||
<a href=db_action.php?table=$table&query=$urlquery&last_pos=$last&detail=$detail>Next $entries_to_show</a><br>
|
||||
";
|
||||
} else {
|
||||
echo "<br>";
|
||||
}
|
||||
if ($detail == "high") {
|
||||
echo "
|
||||
|
@ -190,4 +118,4 @@ function append_sql_query($original,$addition,$first) {
|
|||
}
|
||||
|
||||
page_tail();
|
||||
?>
|
||||
} ?>
|
||||
|
|
|
@ -26,6 +26,163 @@ function lookup_user_auth($auth) {
|
|||
}
|
||||
}
|
||||
|
||||
class SqlQueryString {
|
||||
var $table;
|
||||
var $query;
|
||||
function SqlQueryString($table, $query) { $this->table = $table; $this->query = $query; }
|
||||
function add($clause) {
|
||||
if (!$this->query) {
|
||||
$this->query .= "where $clause";
|
||||
} else {
|
||||
$this->query .= " and $clause";
|
||||
}
|
||||
}
|
||||
function addclause($clause) {
|
||||
if ($clause) {
|
||||
$this->add($clause);
|
||||
}
|
||||
}
|
||||
function addeq($name, $value) {
|
||||
if (strlen($value)) {
|
||||
$this->add("$name = $value");
|
||||
}
|
||||
}
|
||||
function addeqnz($name, $value) {
|
||||
if (strlen($value) && $value > 0) {
|
||||
$this->add("$name = $value");
|
||||
}
|
||||
}
|
||||
function addgt($name, $value) {
|
||||
if (strlen($value) && $value > 0) {
|
||||
$this->add("$name > $value");
|
||||
}
|
||||
}
|
||||
|
||||
function count() {
|
||||
$count_query = "select count(*) as cnt from $this->table $this->query";
|
||||
$result = mysql_query($count_query);
|
||||
$res = mysql_fetch_object($result);
|
||||
return $res->cnt;
|
||||
}
|
||||
|
||||
function get_select_query($entries_to_show, $start_at) {
|
||||
if ($entries_to_show) {
|
||||
if ($start_at) {
|
||||
return "select * from $this->table $this->query limit $start_at,$entries_to_show";
|
||||
} else {
|
||||
return "select * from $this->table $this->query limit $entries_to_show";
|
||||
}
|
||||
} else {
|
||||
return "select * from $this->table $this->query";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function build_sql_query($table)
|
||||
{
|
||||
parse_str(getenv("QUERY_STRING"));
|
||||
|
||||
$q = new SqlQueryString($table, $query);
|
||||
|
||||
$q->addclause($clauses);
|
||||
$q->addeq('id', $id);
|
||||
$q->addeq('platformid', $plat_id);
|
||||
$q->addeq('appid', $app_id);
|
||||
$q->addeq('workunitd', $wu_id);
|
||||
$q->addeq('hostid', $hostid);
|
||||
$q->addeq('userid', $userid);
|
||||
$q->addeq('teamid', $team_id);
|
||||
if ($nsecs) {
|
||||
$received_time = time() - $nsecs;
|
||||
}
|
||||
$q->addgt('received_time', $received_time);
|
||||
$q->addeqnz('server_state', $result_server_state);
|
||||
$q->addeqnz('outcome', $result_outcome);
|
||||
$q->addeqnz('client_state', $result_client_state);
|
||||
|
||||
if (strlen($sort_by)) {
|
||||
$q->query .= " order by $sort_by desc";
|
||||
}
|
||||
|
||||
return $q;
|
||||
}
|
||||
|
||||
function link_results($n, $mq, $query) {
|
||||
if ($n == '0') { // intentional compare by string
|
||||
return "0";
|
||||
} else {
|
||||
return "<a href=db_action.php?table=result&query=$mq&$query&sort_by=received_time&detail=low>$n</a>";
|
||||
}
|
||||
}
|
||||
|
||||
function show_result_summary()
|
||||
{
|
||||
$server_state = array();
|
||||
$outcome = array();
|
||||
$client_state = array();
|
||||
|
||||
for ($ss=1; $ss<6; $ss++) {
|
||||
$server_state[$ss] = 0;
|
||||
}
|
||||
for ($ro=0; $ro<6; $ro++) {
|
||||
$outcome[$ro] = 0;
|
||||
}
|
||||
for ($cs=1; $cs<6; $cs++) {
|
||||
$client_state[$cs] = 0;
|
||||
}
|
||||
|
||||
$q = build_sql_query('result');
|
||||
$main_query = $q->get_select_query(0,0);
|
||||
$urlquery = urlencode($q->query);
|
||||
echo "<p>Query: <b>$main_query</b><p>\n";
|
||||
$result = mysql_query($main_query);
|
||||
$ntotal =0; // TODO: how to count $result?
|
||||
while ($res = mysql_fetch_object($result)) {
|
||||
$server_state[$res->server_state] += 1;
|
||||
$ntotal += 1;
|
||||
if ($res->server_state == 5) {
|
||||
$outcome[$res->outcome] += 1;
|
||||
if ($res->outcome == 3) {
|
||||
$client_state[$res->client_state] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql_free_result($result);
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr valign=top>";
|
||||
echo "<td><h2>" . link_results("$ntotal results", $urlquery, '') . "</h2></td>";
|
||||
echo "<td><h2>" . link_results("'Over' results", $urlquery, "result_server_state=5") . "</h2></td>";
|
||||
echo "<td><h2>" . link_results("'Client error' results", $urlquery, "result_outcome=3") . "</h2></td>";
|
||||
echo "</tr>";
|
||||
echo "<tr valign=top>";
|
||||
echo "<td><table border=2 cellpadding=4\n";
|
||||
echo "<tr><th>Server state</th><th># results</th></tr>\n";
|
||||
for ($ss=1; $ss<6; $ss++) {
|
||||
row2(result_server_state_string($ss),
|
||||
link_results($server_state[$ss], $urlquery,"result_server_state=$ss"));
|
||||
}
|
||||
echo "</table></td>";
|
||||
|
||||
echo "<td><table border=2 cellpadding=4\n";
|
||||
echo "<tr><th>Outcome</th><th># results</th></tr>\n";
|
||||
for ($ro=0; $ro<6; $ro++) {
|
||||
c_row2(outcome_color($ro), result_outcome_string($ro),
|
||||
link_results($outcome[$ro], $urlquery, "result_outcome=$ro"));
|
||||
}
|
||||
echo "</table></td>";
|
||||
|
||||
echo "<td><table border=2 cellpadding=4\n";
|
||||
echo "<tr><th>Client state</th><th># results</th></tr>\n";
|
||||
for ($cs=1; $cs<6; $cs++) {
|
||||
row2(result_client_state_string($cs),
|
||||
link_results($client_state[$cs], $urlquery, "result_client_state=$cs"));
|
||||
}
|
||||
print "</td></table>";
|
||||
print "</table>";
|
||||
|
||||
}
|
||||
|
||||
function result_server_state_select() {
|
||||
echo "
|
||||
<select name=result_server_state>
|
||||
|
|
|
@ -4,82 +4,10 @@
|
|||
|
||||
require_once("util_ops.inc");
|
||||
|
||||
function link_results($n, $query) {
|
||||
global $received_time;
|
||||
if ($n == 0) {
|
||||
return "0";
|
||||
} else {
|
||||
return "<a href=db_action.php?table=result&$query&received_time=$received_time&sort_by=received_time&detail=low>$n</a>";
|
||||
}
|
||||
}
|
||||
|
||||
db_init();
|
||||
page_head("Result summary");
|
||||
|
||||
$server_state = array();
|
||||
$outcome = array();
|
||||
$client_state = array();
|
||||
|
||||
$nsecs = $_GET["nsecs"];
|
||||
|
||||
for ($ss=1; $ss<6; $ss++) {
|
||||
$server_state[$ss] = 0;
|
||||
}
|
||||
for ($ro=0; $ro<6; $ro++) {
|
||||
$outcome[$ro] = 0;
|
||||
}
|
||||
for ($cs=1; $cs<6; $cs++) {
|
||||
$client_state[$cs] = 0;
|
||||
}
|
||||
|
||||
$x = $nsecs/3600.;
|
||||
echo "Results that have finished in last $x hours:\n";
|
||||
$received_time = time() - $nsecs;
|
||||
$result = mysql_query("select * from result where received_time > $received_time");
|
||||
$ntotal =0; // TODO: how to count $result?
|
||||
while ($res = mysql_fetch_object($result)) {
|
||||
$server_state[$res->server_state] += 1;
|
||||
$ntotal += 1;
|
||||
if ($res->server_state == 5) {
|
||||
$outcome[$res->outcome] += 1;
|
||||
if ($res->outcome == 3) {
|
||||
$client_state[$res->client_state] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql_free_result($result);
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr valign=top>";
|
||||
echo "<td><h2><a href=db_action.php?table=result&received_time=$received_time&sort_by=received_time&detail=low>$ntotal results</a></h2></td>";
|
||||
echo "<td><h2><a href=db_action.php?table=result&received_time=$received_time&sort_by=received_time&detail=low&result_server_state=5>'Over' results</a></h2></td>";
|
||||
echo "<td><h2><a href=db_action.php?table=result&received_time=$received_time&sort_by=received_time&detail=low&result_outcome=3>'Client error' results</a></h2></td>";
|
||||
echo "</tr>";
|
||||
echo "<tr valign=top>";
|
||||
echo "<td><table border=2 cellpadding=4\n";
|
||||
echo "<tr><th>Server state</th><th># results</th></tr>\n";
|
||||
for ($ss=1; $ss<6; $ss++) {
|
||||
row2(result_server_state_string($ss),
|
||||
link_results($server_state[$ss], "result_server_state=$ss"));
|
||||
}
|
||||
echo "</table></td>";
|
||||
|
||||
echo "<td><table border=2 cellpadding=4\n";
|
||||
echo "<tr><th>Outcome</th><th># results</th></tr>\n";
|
||||
for ($ro=0; $ro<6; $ro++) {
|
||||
c_row2(outcome_color($ro), result_outcome_string($ro),
|
||||
link_results($outcome[$ro], "result_outcome=$ro"));
|
||||
}
|
||||
echo "</table></td>";
|
||||
|
||||
echo "<td><table border=2 cellpadding=4\n";
|
||||
echo "<tr><th>Client state</th><th># results</th></tr>\n";
|
||||
for ($cs=1; $cs<6; $cs++) {
|
||||
row2(result_client_state_string($cs),
|
||||
link_results($client_state[$cs], "result_client_state=$cs"));
|
||||
}
|
||||
print "</td></table>";
|
||||
print "</table>";
|
||||
show_result_summary();
|
||||
|
||||
page_tail();
|
||||
} ?>
|
||||
|
|
Loading…
Reference in New Issue