aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/model/TagStats.java4
-rw-r--r--src/main/java/com/juick/service/SubscriptionServiceImpl.java6
-rw-r--r--src/main/java/com/juick/service/TagService.java5
-rw-r--r--src/main/java/com/juick/service/TagServiceImpl.java7
4 files changed, 9 insertions, 13 deletions
diff --git a/src/main/java/com/juick/model/TagStats.java b/src/main/java/com/juick/model/TagStats.java
index ce6c8139..c5649a1d 100644
--- a/src/main/java/com/juick/model/TagStats.java
+++ b/src/main/java/com/juick/model/TagStats.java
@@ -19,10 +19,12 @@ package com.juick.model;
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+
/**
* Created by vitalyster on 01.12.2016.
*/
-public class TagStats {
+public class TagStats implements Serializable {
private Tag tag;
private int usageCount;
diff --git a/src/main/java/com/juick/service/SubscriptionServiceImpl.java b/src/main/java/com/juick/service/SubscriptionServiceImpl.java
index fae1b824..4aa5b5ac 100644
--- a/src/main/java/com/juick/service/SubscriptionServiceImpl.java
+++ b/src/main/java/com/juick/service/SubscriptionServiceImpl.java
@@ -62,8 +62,8 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
.filter(u -> !userService.isInBL(u.getUid(), msg.getUser().getUid()))
.toList();
List<User> users = ListUtils.union(subscribers, mentionedUsers);
- List<Integer> tags = tagService.getMessageTagsIDs(mid);
- List<String> tagsStr = tagService.getMessageTags(mid).stream().map(t -> t.getTag().getName())
+ var tags = tagService.getMessageTags(mid);
+ List<String> tagsStr = tags.stream().map(t -> t.getTag().getName())
.toList();
Set<Integer> set = users.stream()
@@ -80,7 +80,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
+
" AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN (:ids) and st.suser_id = bt.user_id)",
new MapSqlParameterSource()
- .addValue("ids", tags)
+ .addValue("ids", tags.stream().map(t -> t.getTag().getId()).collect(Collectors.toList()))
.addValue("uid", uid)
.addValue("authorUid", author.getUid()),
Integer.class);
diff --git a/src/main/java/com/juick/service/TagService.java b/src/main/java/com/juick/service/TagService.java
index 84bde121..ef937460 100644
--- a/src/main/java/com/juick/service/TagService.java
+++ b/src/main/java/com/juick/service/TagService.java
@@ -21,6 +21,7 @@ import com.juick.model.Tag;
import com.juick.model.User;
import com.juick.model.TagStats;
import org.apache.commons.lang3.tuple.Pair;
+import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.util.Collection;
@@ -50,13 +51,13 @@ public interface TagService {
List<TagStats> getTagStats();
+ @CacheEvict(value = "message_tags", key = "#mid")
Set<Tag> updateTags(int mid, Collection<Tag> newTags);
Pair<String, Set<Tag>> fromString(String txt);
+ @Cacheable(value = "message_tags")
List<TagStats> getMessageTags(int mid);
- List<Integer> getMessageTagsIDs(int mid);
-
boolean blacklistTag(User user, Tag tag);
}
diff --git a/src/main/java/com/juick/service/TagServiceImpl.java b/src/main/java/com/juick/service/TagServiceImpl.java
index c9384f6a..90d0fc83 100644
--- a/src/main/java/com/juick/service/TagServiceImpl.java
+++ b/src/main/java/com/juick/service/TagServiceImpl.java
@@ -278,13 +278,6 @@ public class TagServiceImpl extends BaseJdbcService implements TagService {
}
@Override
- public List<Integer> getMessageTagsIDs(final int mid) {
- return getJdbcTemplate().queryForList(
- "SELECT tag_id FROM messages_tags WHERE message_id = ?",
- Integer.class, mid);
- }
-
- @Override
public boolean blacklistTag(User user, Tag tag) {
int rowcount = getNamedParameterJdbcTemplate().update(
"DELETE FROM bl_tags WHERE tag_id = :tid AND user_id = :uid",