From 22358b0c64243f09dbbb4a3038f8956390ac63f1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 1 Mar 2019 16:51:10 +0300 Subject: Drop ugnich index-like tags column --- .../java/com/juick/service/MessagesServiceImpl.java | 17 +++-------------- src/main/java/com/juick/service/TagServiceImpl.java | 5 +---- 2 files changed, 4 insertions(+), 18 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index 58108cdd..8fc2ceed 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -132,24 +132,13 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ } int mid = simpleJdbcInsert.executeAndReturnKey(insertMap).intValue(); if (mid > 0) { - String tagsNames = StringUtils.EMPTY; if (CollectionUtils.isNotEmpty(tags)) { - StringBuilder tasNamesBuilder = new StringBuilder(); List params = new ArrayList<>(tags.size()); - boolean next = false; - for (Tag tag : tags) { - if (next) { - tasNamesBuilder.append(" "); - } else - next = true; - - tasNamesBuilder.append(tag.getName()); params.add(new Object[]{mid, tag.TID}); } - tagsNames = tasNamesBuilder.toString(); getJdbcTemplate().batchUpdate( "INSERT INTO messages_tags(message_id, tag_id) VALUES (?, ?)", @@ -157,9 +146,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ } getJdbcTemplate().update( - "INSERT INTO messages_txt(message_id, tags, txt, updated_at) VALUES (?, ?, ?, ?)", - new Object[]{mid, tagsNames, txt, Timestamp.from(now)}, - new int[]{Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP}); + "INSERT INTO messages_txt(message_id, txt, updated_at) VALUES (?, ?, ?)", + new Object[]{mid, txt, Timestamp.from(now)}, + new int[]{Types.INTEGER, Types.VARCHAR, Types.TIMESTAMP}); getJdbcTemplate().update("UPDATE users SET lastmessage=?, last_seen=? where id=?", Timestamp.from(now), Timestamp.from(now), uid); } diff --git a/src/main/java/com/juick/service/TagServiceImpl.java b/src/main/java/com/juick/service/TagServiceImpl.java index 2a7928e7..750a9c6e 100644 --- a/src/main/java/com/juick/service/TagServiceImpl.java +++ b/src/main/java/com/juick/service/TagServiceImpl.java @@ -201,11 +201,8 @@ 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)); - List result = getMessageTags(mid).stream() + return 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 -- cgit v1.2.3