From 2bc4ccc437bb036de4ac5db23af8a276f1a708d5 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Thu, 19 Dec 2013 02:04:18 +0700 Subject: SubscriptionQueries.getJIDSubscribedToUserAndTags --- src/com/juick/server/SubscriptionsQueries.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/com/juick/server/SubscriptionsQueries.java b/src/com/juick/server/SubscriptionsQueries.java index 9f9468cd..ca382fc7 100644 --- a/src/com/juick/server/SubscriptionsQueries.java +++ b/src/com/juick/server/SubscriptionsQueries.java @@ -43,6 +43,28 @@ public class SubscriptionsQueries { return jids; } + public static ArrayList getJIDSubscribedToUserAndTags(Connection sql, int uid, int mid) { + ArrayList jids = new ArrayList(); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT DISTINCT jid FROM jids WHERE active=1 AND user_id IN (SELECT suser_id FROM subscr_users WHERE user_id=? UNION SELECT suser_id FROM subscr_tags INNER JOIN messages_tags ON (messages_tags.message_id=? AND subscr_tags.tag_id=messages_tags.tag_id))"); + stmt.setInt(1, uid); + stmt.setInt(2, mid); + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + jids.add(rs.getString(1)); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return jids; + } + public static ArrayList getJIDSubscribedToComments(Connection sql, int mid, int ignore_uid) { ArrayList jids = new ArrayList(); -- cgit v1.2.3