From eeb59ea1f2e2bd4307573d01238c8c4ce35d4179 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 30 Apr 2018 18:58:11 +0300 Subject: server: fix classic likes counter --- .../src/main/java/com/juick/service/MessagesServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'juick-server-jdbc/src/main') diff --git a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java index 8554b35f..b64d7fd9 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -217,7 +217,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Transactional void updateRepliesBy(int mid) { - List users = getJdbcTemplate().queryForList("SELECT users.nick FROM replies " + + List users = getJdbcTemplate().queryForList("SELECT DISTINCT users.nick FROM replies " + "INNER JOIN users ON replies.user_id=users.id WHERE replies.message_id=? " + "GROUP BY replies.user_id ORDER BY COUNT(replies.reply_id) DESC LIMIT 5", String.class, mid); String result = users.stream().map(u -> "@" + u).collect(Collectors.joining(",")); @@ -243,7 +243,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Override public List listReactions() { - return jdbcTemplate.query("SELECT like_id, description FROM reactions", (RowMapper) (rs, rowNum) -> { + return jdbcTemplate.query("SELECT like_id, description FROM reactions", (rs, rowNum) -> { Reaction reaction = new Reaction(rs.getInt("like_id")); reaction.setDescription(rs.getString("description")); return reaction; @@ -330,7 +330,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ + "messages.ts," + "messages.readonly, messages.privacy, messages.replies," + "messages.attach, messages.place_id, messages.lat," - + "messages.lon, COUNT(favorites.user_id) as likes, messages.hidden," + + "messages.lon, COUNT(DISTINCT favorites.user_id) as likes, messages.hidden," + "txt.tags, txt.repliesby, txt.txt, '' as q, messages.updated, 0 as to_uid, " + "NULL as to_name FROM messages " + "INNER JOIN users ON messages.user_id = users.id " @@ -421,7 +421,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Override public List getMessageRecommendations(final int mid) { return getJdbcTemplate().queryForList( - "SELECT users.nick FROM favorites INNER JOIN users " + + "SELECT DISTINCT users.nick FROM favorites INNER JOIN users " + "ON (favorites.message_id = ? AND favorites.user_id = users.id) WHERE favorites.like_id=1", new Object[]{mid}, String.class); @@ -783,7 +783,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ + "messages.ts," + "messages.readonly,messages.privacy,messages.replies," + "messages.attach,messages.place_id,messages.lat," - + "messages.lon,COUNT(favorites.user_id) AS likes,messages.hidden," + + "messages.lon,COUNT(DISTINCT favorites.user_id) AS likes,messages.hidden," + "messages_txt.tags,messages_txt.repliesby, messages_txt.txt, '' as q, " + "messages.updated, 0 as to_uid, NULL as to_name " + "FROM (messages INNER JOIN messages_txt " -- cgit v1.2.3