From ca61881a9238628ef0419980c274ea8b374488ba Mon Sep 17 00:00:00 2001 From: Christian Beer Date: Mon, 14 Dec 2015 14:27:02 +0100 Subject: [PATCH] Web: improve the reselection of old UOTD This will pick a more random UOTD if no new profiles are available and old ones are reselected. --- html/inc/uotd.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/html/inc/uotd.inc b/html/inc/uotd.inc index 932a4c5f9f..00e9ab3e56 100644 --- a/html/inc/uotd.inc +++ b/html/inc/uotd.inc @@ -110,9 +110,10 @@ function select_uotd($force_new = false) { echo "no new verified profile found, selecting old UOTD that was shown least recently\n"; $result->free(); // If all verified profiles have been selected as UOTD, - // reshow the one that was shown least recently. + // reshow a random one of the 100 least recently shown profiles. // - $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"); + $inner = "SELECT profile.userid FROM profile,user WHERE profile.userid=user.id AND verification=1 AND uotd_time>0 ORDER BY uotd_time ASC LIMIT 100"; + $result = $db->do_query("SELECT * from ($inner) ORDER BY RAND() LIMIT 1"); } if (!$result || $result->num_rows == 0) {