From 0f0009ff1c86fd8ae3af122851034eac21645e11 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 20 Apr 2018 11:27:46 +0300 Subject: server: fix compatibility with likes --- .../main/java/com/juick/service/MessagesServiceImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'juick-server-jdbc/src/main/java/com') 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 7816ef67..d339d229 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 @@ -337,7 +337,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ + "INNER JOIN messages_txt AS txt " + "ON messages.message_id = txt.message_id " + "LEFT JOIN favorites " - + "ON messages.message_id = favorites.message_id " + + "ON messages.message_id = favorites.message_id AND favorites.like_id=1 " + "WHERE messages.message_id = ? " + "GROUP BY mid, rid, replyto, uid, nick, banned, ago, messages.ts, readonly, " + "privacy, replies, attach, place_id, lat, lon, tags, repliesby, q", @@ -422,7 +422,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ public List getMessageRecommendations(final int mid) { return getJdbcTemplate().queryForList( "SELECT users.nick FROM favorites INNER JOIN users " + - "ON (favorites.message_id = ? AND favorites.user_id = users.id)", + "ON (favorites.message_id = ? AND favorites.user_id = users.id) WHERE favorites.like_id=1", new Object[]{mid}, String.class); } @@ -806,8 +806,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Override public Map> updateReactionsFor(final List mids) { - return getNamedParameterJdbcTemplate().query("select f.message_id as mid, f.like_id as lid, " + - "r.description as desc, count(f.like_id) as count" + + return getNamedParameterJdbcTemplate().query("select f.message_id as mid, f.like_id as lid," + + " r.description as descr, count(f.like_id) as cnt" + " from favorites f LEFT JOIN reactions r ON f.like_id = r.like_id " + " where f.message_id IN (:mids) " + " group by f.message_id, f.like_id", new MapSqlParameterSource("mids", mids), (ResultSet rs) -> { @@ -815,10 +815,10 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ while (rs.next()) { - int messageId = rs.getInt("message_id"); - int likeId = rs.getInt("like_id"); - int count = rs.getInt("count"); - String description = rs.getString("description"); + int messageId = rs.getInt("mid"); + int likeId = rs.getInt("lid"); + int count = rs.getInt("cnt"); + String description = rs.getString("descr"); Reaction reaction = new Reaction(likeId); reaction.setCount(count); reaction.setDescription(description); -- cgit v1.2.3