Limit user of the day selection pool to users who have never been picked before (if there are any)

(DBOINCP-110)
This commit is contained in:
Tristan Olive 2015-06-08 13:16:39 -04:00
parent 597f72b3d3
commit 19a23d3dfb
1 changed files with 9 additions and 0 deletions

View File

@ -1176,6 +1176,14 @@ function boincuser_home_page() {
$active_users[] = $user_with_credit->id;
}
$active_users = implode(',', $active_users);
// Limit to users who have never been user of the day, if there are any
$never_been_picked = db_result(db_query("
SELECT COUNT(*)
FROM {boincuser}
WHERE uotd_time = 0
" . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '')
));
// Select a user of the day randomly from the pool
$new_uotd_uid = db_result(db_query("
SELECT
n.uid
@ -1184,6 +1192,7 @@ function boincuser_home_page() {
WHERE n.type = 'profile'
AND n.status = 1
AND n.moderate = 0
" . ($never_been_picked ? " AND bu.uotd_time = 0 " : '') . "
" . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') . "
ORDER BY RAND()
LIMIT 1"