From 3cf580867600494615a7bdc9ab43ef0735d5aedb Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 1 Feb 2024 15:19:49 +0300 Subject: Do not block JDBC connection to get message tags --- src/main/java/com/juick/service/MessagesServiceImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index 8292f4fd..6874c7bc 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -92,10 +92,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ msg.setReplies(rs.getInt(10)); msg.setAttachmentType(rs.getString(11)); msg.Hidden = rs.getBoolean(13); - if (msg.getRid() == 0) { - msg.setTags(tagService.getMessageTags(msg.getMid()).stream() - .map(TagStats::getTag).collect(Collectors.toSet())); - } msg.setRepliesBy(rs.getString(15)); msg.setText(rs.getString(16)); msg.setReplyQuote(MessageUtils.formatQuote(rs.getString(17))); @@ -822,6 +818,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ List msgs = getNamedParameterJdbcTemplate().query(query, new MapSqlParameterSource("ids", mids) .addValue("uid", uid), messageMapper); + + msgs.forEach(m -> m.setTags(tagService.getMessageTags(m.getMid()).stream() + .map(TagStats::getTag).collect(Collectors.toSet()))); Map> likes = updateReactionsFor(mids); msgs.forEach(i -> i.setReactions(likes.get(i.getMid()))); msgs.sort(Comparator.comparing(item -> mids.indexOf(item.getMid()))); -- cgit v1.2.3