From 3caf993af6742740f9c3997c8e072cc681b10118 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Fri, 4 Apr 2014 14:57:42 +0700 Subject: getBLUsers, getBLTags, setPopular --- src/com/juick/server/MessagesQueries.java | 34 ++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/com/juick/server/MessagesQueries.java') diff --git a/src/com/juick/server/MessagesQueries.java b/src/com/juick/server/MessagesQueries.java index 1f4c8408..d2254575 100644 --- a/src/com/juick/server/MessagesQueries.java +++ b/src/com/juick/server/MessagesQueries.java @@ -291,21 +291,21 @@ public class MessagesQueries { try { if (visitor_uid > 1) { if (before > 0) { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE message_id=-1 AND (privacy>0 OR user_id=?) AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) ORDER BY message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE message_id0 OR user_id=?) AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) ORDER BY message_id DESC LIMIT 20"); stmt.setInt(1, before); stmt.setInt(2, visitor_uid); stmt.setInt(3, visitor_uid); } else { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE popular>=-1 AND (privacy>0 OR user_id=?) AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) ORDER BY message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE hidden=0 AND (privacy>0 OR user_id=?) AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) ORDER BY message_id DESC LIMIT 20"); stmt.setInt(1, visitor_uid); stmt.setInt(2, visitor_uid); } } else { if (before > 0) { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE message_id=-1 AND privacy>0 ORDER BY message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE message_id0 ORDER BY message_id DESC LIMIT 20"); stmt.setInt(1, before); } else { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE popular>=-1 AND privacy>0 ORDER BY message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE hidden=0 AND privacy>0 ORDER BY message_id DESC LIMIT 20"); } } @@ -890,9 +890,17 @@ public class MessagesQueries { PreparedStatement stmt = null; try { - stmt = sql.prepareStatement("UPDATE messages SET popular=? WHERE message_id=?"); - stmt.setInt(1, popular); - stmt.setInt(2, mid); + if (popular == -2) { + stmt = sql.prepareStatement("UPDATE messages SET hidden=1 WHERE message_id=?"); + stmt.setInt(1, mid); + } else if (popular == -1) { + stmt = sql.prepareStatement("UPDATE messages SET popular=0 WHERE message_id=?"); + stmt.setInt(1, mid); + } else { + stmt = sql.prepareStatement("UPDATE messages SET popular=? WHERE message_id=?"); + stmt.setInt(1, popular); + stmt.setInt(2, mid); + } ret = stmt.executeUpdate() > 0; } catch (SQLException e) { System.err.println(e); @@ -900,6 +908,18 @@ public class MessagesQueries { Utils.finishSQL(null, stmt); } + if (popular == -1) { + try { + stmt = sql.prepareStatement("INSERT INTO top_ignore_messages VALUES (?)"); + stmt.setInt(1, mid); + stmt.executeUpdate(); + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(null, stmt); + } + } + return ret; } } -- cgit v1.2.3