aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java2
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java7
2 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index 7e366a01..0a010929 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -987,7 +987,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "INNER JOIN messages ON messages.message_id = favorites.message_id "
+ "LEFT JOIN messages_tags ON messages_tags.message_id = messages.message_id "
+ "WHERE COALESCE(messages_tags.tag_id, 0) != 2 AND favorites.ts > TIMESTAMPADD(HOUR, -2, CURRENT_TIMESTAMP) "
- + "AND favorites.user_id != 2 GROUP BY messages.message_id HAVING COUNT(DISTINCT favorites.user_id) > 1;",
+ + "AND NOT EXISTS (SELECT * FROM favorites WHERE user_id = 2) GROUP BY messages.message_id HAVING COUNT(DISTINCT favorites.user_id) > 1;",
Integer.class);
}
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 9ed4b727..252fa432 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -819,6 +819,13 @@ public class ServerTests {
assertThat(nsfw.TID, equalTo(805));
tagService.updateTags(topmid, Collections.singletonList(nsfw));
assertThat(messagesService.getPopularCandidates().isEmpty(), is(true));
+ User recommender = userService.createUser("recommender", "x").orElseThrow(IllegalStateException::new);
+ int anotherMid = messagesService.createMessage(ugnich.getUid(), "top2", null, null);
+ messagesService.recommendMessage(anotherMid, freefd.getUid());
+ messagesService.recommendMessage(anotherMid, recommender.getUid());
+ assertThat(messagesService.getPopularCandidates().get(0), is(anotherMid));
+ messagesService.recommendMessage(anotherMid, serviceUser.getUid());
+ assertThat(messagesService.getPopularCandidates().isEmpty(), is(true));
}
@Test