diff options
Diffstat (limited to 'src/com/juick/server/AdsQueries.java')
-rw-r--r-- | src/com/juick/server/AdsQueries.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/com/juick/server/AdsQueries.java b/src/com/juick/server/AdsQueries.java index f1b37fb1..0fb4c0a6 100644 --- a/src/com/juick/server/AdsQueries.java +++ b/src/com/juick/server/AdsQueries.java @@ -28,7 +28,11 @@ import java.sql.SQLException; public class AdsQueries { public static int getAdMID(Connection sql, int uid) { - return SQLHelpers.getInt(sql, "SELECT message_id FROM ads_messages WHERE message_id NOT IN (SELECT message_id FROM ads_messages_log WHERE user_id=? AND ts>UNIX_TIMESTAMP()-60*60*24 GROUP BY message_id HAVING COUNT(*)>2) ORDER BY RAND() LIMIT 1", uid, 0); + if (uid > 0) { + return SQLHelpers.getInt(sql, "SELECT message_id FROM ads_messages WHERE message_id NOT IN (SELECT message_id FROM ads_messages_log WHERE user_id=? AND ts>UNIX_TIMESTAMP()-60*60*24 GROUP BY message_id HAVING COUNT(*)>2) ORDER BY RAND() LIMIT 1", uid, 0); + } else { + return SQLHelpers.getInt(sql, "SELECT message_id FROM ads_messages ORDER BY RAND() LIMIT 1", 0); + } } public static void logAdMID(Connection sql, int uid, int mid) { |