aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-24 16:22:20 +0300
committerGravatar Vitaly Takmazov2016-06-24 16:22:20 +0300
commiteca30236892175d7071e6d0d39f474148d655ffa (patch)
treeb8af4a7c5a2c791cb3e7f14f0b62c26fc06f488e
parentc1fcf803adfe06a0a54b3e51c4fd2d67e6b732d8 (diff)
fix tags queries
-rw-r--r--src/main/java/com/juick/server/SubscriptionsQueries.java11
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));
}