diff options
author | Vitaly Takmazov | 2019-03-01 16:51:10 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-03-01 16:51:10 +0300 |
commit | 22358b0c64243f09dbbb4a3038f8956390ac63f1 (patch) | |
tree | 1ed716802992fc9b0ab3f014a1d8d0a456c7a7f7 /src/main/java/com/juick | |
parent | fdef6b03b20654d4c90349916a9a15c6569c677a (diff) |
Drop ugnich index-like tags column
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 17 | ||||
-rw-r--r-- | src/main/java/com/juick/service/TagServiceImpl.java | 5 |
2 files changed, 4 insertions, 18 deletions
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<Object[]> 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<Tag> 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 |