From fa9788960e934d9b78e5968eb2c384254218090a Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 15 Apr 2018 19:04:31 +0300 Subject: server: fix tags cache --- .../src/main/java/com/juick/service/TagServiceImpl.java | 5 ++++- juick-server/src/test/java/com/juick/server/tests/ServerTests.java | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java index 90b70612..403dac09 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java @@ -214,8 +214,11 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { newTags.stream().filter(t -> !currentTags.contains(t)) .forEach(t -> getJdbcTemplate().update("INSERT INTO messages_tags(message_id,tag_id) VALUES (?,?)", mid, t.TID)); - return getMessageTags(mid).stream() + List result = getMessageTags(mid).stream() .map(TagStats::getTag).collect(Collectors.toList()); + jdbcTemplate.update("UPDATE messages_txt SET tags=? WHERE message_id=?", result.stream() + .map(Tag::getName).collect(Collectors.joining(" ")), mid); + return result; } @Override diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java index cdf10326..1acc0c15 100644 --- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java @@ -651,6 +651,7 @@ public class ServerTests { commandsManager.processCommand(user, "#" + mid + " *there", emptyUri).getText()); assertEquals("number of tags should match", 2, tagService.getMessageTags(mid).size()); + assertThat(messagesService.getMessage(mid).getTags().size(), is(2)); assertEquals("should be blacklisted", "Tag added to your blacklist", commandsManager.processCommand(readerUser, "BL *there", emptyUri).getText()); assertEquals("number of subscribed users should match", 0, -- cgit v1.2.3