Web: fix selection of UOTD

The default for uotd_time in the profile table is NULL but new profiles created after commit 6543928 have uotd_time=0. This means they are not eligible for UOTD because the default candidate queries only check if uotd_time is null. This fixes that and considers NULL and 0 as 'profile has not been UOTD but can be a candidate'.
This commit is contained in:
Christian Beer 2015-12-14 11:29:48 +01:00
parent 9b8c291a87
commit 7e3d0802af
2 changed files with 4 additions and 4 deletions

View File

@ -47,7 +47,7 @@ function show_uotd($profile) {
// return the last UOTD profile, or null
//
function get_current_uotd() {
$profiles = BoincProfile::enum("uotd_time is not NULL", "ORDER BY uotd_time DESC LIMIT 1");
$profiles = BoincProfile::enum("uotd_time is not NULL and uotd_time>0", "ORDER BY uotd_time DESC LIMIT 1");
if (sizeof($profiles)) {
return $profiles[0];
}
@ -112,7 +112,7 @@ function select_uotd($force_new = false) {
// If all verified profiles have been selected as UOTD,
// reshow the one that was shown least recently.
//
$result = $db->do_query("SELECT * FROM profile,user WHERE profile.userid=user.id AND verification=1 ORDER BY uotd_time ASC LIMIT 1");
$result = $db->do_query("SELECT * FROM profile,user WHERE profile.userid=user.id AND verification=1 AND uotd_time>0 ORDER BY uotd_time ASC LIMIT 1");
}
if (!$result || $result->num_rows == 0) {
@ -164,7 +164,7 @@ function default_uotd_candidates_query(){
$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 .= " AND (uotd_time IS NULL or uotd_time=0) ";
$query .= "ORDER BY RAND()";
return $query;
}

View File

@ -46,7 +46,7 @@ if (function_exists('profile_screen_query')) {
$query = "select * from profile, user where profile.userid=user.id "
." and has_picture>0 "
." and verification=0 "
." and uotd_time is null "
." and (uotd_time is null or uotd_time=0) "
." and expavg_credit>1 "
." and (response1 <> '' or response2 <> '') "
." order by recommend desc limit 20"