Show UOTD counter in the ops page (from Eric Myers)

svn path=/trunk/boinc/; revision=11533
This commit is contained in:
Rytis Slatkevičius 2006-11-16 19:03:07 +00:00
parent 45d3be605b
commit d4d93cdc25
2 changed files with 53 additions and 10 deletions

View File

@ -58,17 +58,8 @@ function build_uotd_page() {
//
if (function_exists('uotd_candidates_query')) {
$query = uotd_candidates_query();
} else if (profile_screening()) {
$query = "SELECT * FROM profile,user WHERE profile.userid=user.id ";
$query .= " AND verification=1 ";
$query .= " AND expavg_credit>1 ";
$query .= " AND uotd_time IS NULL ";
$query .= "ORDER BY RAND()";
} else {
$query = "SELECT * FROM profile,user WHERE profile.userid=user.id ";
$query .= " AND verification=1 ";
$query .= " AND uotd_time IS NULL ";
$query .= "ORDER BY RAND()";
$query = default_uotd_candidates_query();
}
$result = mysql_query($query);
@ -113,4 +104,42 @@ function build_uotd_page() {
echo "Chose user $user->id as UOTD\n";
}
// This is the default policy for choosing the UOTD on any BOINC project.
// To override this with your own policy, create a similar function in
// your own project.inc called uotd_candidates_query()
function default_uotd_candidates_query(){
if (profile_screening()) {
$query = "SELECT * FROM profile,user WHERE profile.userid=user.id ";
$query .= " AND verification=1 ";
$query .= " AND expavg_credit>1 ";
$query .= " AND uotd_time IS NULL ";
$query .= "ORDER BY RAND()";
} else {
$query = "SELECT * FROM profile,user WHERE profile.userid=user.id ";
$query .= " AND verification=1 ";
$query .= " AND uotd_time IS NULL ";
$query .= "ORDER BY RAND()";
}
return $query;
}
// get a list of profiles that have been 'approved' for UOTD,
// using a project-specific query if supplied in project.inc
function count_uotd_candidates(){
$n = -1; // negative value returned on error
if (function_exists('uotd_candidates_query')) {
$query = uotd_candidates_query();
} else {
$query = default_uotd_candidates_query();
}
$result = mysql_query($query);
if($result) {
$n = mysql_num_rows($result);
}
mysql_free_result($result);
return $n;
}
?>

View File

@ -3,6 +3,7 @@ $cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
require_once("../inc/db_ops.inc");
require_once("../inc/util_ops.inc");
require_once("../inc/uotd.inc");
$config = get_config();
$cgi_url = parse_config($config, "<cgi_url>");
@ -30,6 +31,19 @@ if (defined('INVITE_CODES')) {
invitation codes.</span></li>\n";
}
$uotd_candidates = count_uotd_candidates();
if ($uotd_candidates > 0) {
if ($uotd_candidates >= UOTD_THRESHOLD*2) {
$color = "#00aa00";
} elseif ($uotd_candidates < UOTD_THRESHOLD) {
$color = "#ff0000";
} else {
$color = "#ff9900";
}
echo "<li><span style='color: ".$color."'>There are ".$uotd_candidates." remaining
candidates for User of the Day.</span></li>\n";
}
echo "</ul>\n";
echo "