From eca30236892175d7071e6d0d39f474148d655ffa Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 24 Jun 2016 16:22:20 +0300 Subject: fix tags queries --- src/main/java/com/juick/server/SubscriptionsQueries.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/com/juick/server/SubscriptionsQueries.java b/src/main/java/com/juick/server/SubscriptionsQueries.java index 3a76e23e..b271435b 100644 --- a/src/main/java/com/juick/server/SubscriptionsQueries.java +++ b/src/main/java/com/juick/server/SubscriptionsQueries.java @@ -6,6 +6,7 @@ package com.juick.server; import com.juick.User; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.util.StringUtils; import java.sql.Connection; import java.sql.PreparedStatement; @@ -55,12 +56,14 @@ public class SubscriptionsQueries { public static List getSubscribedUsers(JdbcTemplate sql, int uid, int mid) { List userids = UserQueries.getUserRead(sql, uid); - List tags = MessagesQueries.getMessageTagsIDs(sql, mid); - List tagUsers = sql.queryForList("SELECT suser_id FROM subscr_tags " + - "WHERE tag_id IN (" + Utils.convertArrayInt2String(tags) + ") AND suser_id!=" + uid, Integer.class); Set set = new HashSet<>(); set.addAll(userids); - set.addAll(tagUsers); + List tags = MessagesQueries.getMessageTagsIDs(sql, mid); + if (tags.size() > 0) { + List tagUsers = sql.queryForList("SELECT suser_id FROM subscr_tags " + + "WHERE tag_id IN (" + StringUtils.arrayToCommaDelimitedString(tags.toArray()) + ") AND suser_id!=" + uid, Integer.class); + set.addAll(tagUsers); + } return UserQueries.getUsersByID(sql, new ArrayList<>(set)); } -- cgit v1.2.3