diff options
author | Vitaly Takmazov | 2016-06-24 16:22:20 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-06-24 16:22:20 +0300 |
commit | eca30236892175d7071e6d0d39f474148d655ffa (patch) | |
tree | b8af4a7c5a2c791cb3e7f14f0b62c26fc06f488e /src/main/java/com | |
parent | c1fcf803adfe06a0a54b3e51c4fd2d67e6b732d8 (diff) |
fix tags queries
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/juick/server/SubscriptionsQueries.java | 11 |
1 files changed, 7 insertions, 4 deletions
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<User> getSubscribedUsers(JdbcTemplate sql, int uid, int mid) { List<Integer> userids = UserQueries.getUserRead(sql, uid); - List<Integer> tags = MessagesQueries.getMessageTagsIDs(sql, mid); - List<Integer> tagUsers = sql.queryForList("SELECT suser_id FROM subscr_tags " + - "WHERE tag_id IN (" + Utils.convertArrayInt2String(tags) + ") AND suser_id!=" + uid, Integer.class); Set<Integer> set = new HashSet<>(); set.addAll(userids); - set.addAll(tagUsers); + List<Integer> tags = MessagesQueries.getMessageTagsIDs(sql, mid); + if (tags.size() > 0) { + List<Integer> 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)); } |