aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-05-12 11:16:34 +0300
committerGravatar Vitaly Takmazov2022-05-12 11:16:34 +0300
commit31cb8c7526b96c6577badb203a336685a806b802 (patch)
tree50f87ff1f39131eed5aaf27f7bebbc8ae582fbd6
parent822af5ae3bda15b0d74100201dc4fca10d12d2c8 (diff)
Update top criterias
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java2
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index 369c508e..4cbd09ee 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -996,7 +996,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 NOT EXISTS (SELECT 1 FROM favorites WHERE message_id = messages.message_id AND user_id = 2) GROUP BY messages.message_id HAVING COUNT(DISTINCT favorites.user_id) > 1;",
+ + "AND NOT EXISTS (SELECT 1 FROM favorites WHERE message_id = messages.message_id AND user_id = 2) GROUP BY messages.message_id HAVING COUNT(DISTINCT favorites.user_id) > 2;",
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 18aa41f7..e5b4562c 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -830,6 +830,9 @@ public class ServerTests {
int anotherMid = messagesService.createMessage(ugnich.getUid(), "top2", null, Set.of());
messagesService.recommendMessage(anotherMid, freefd.getUid());
messagesService.recommendMessage(anotherMid, recommender.getUid());
+ assertThat(messagesService.getPopularCandidates().isEmpty(), is(true));
+ User recommender3 = userService.createUser("recommender3", "x").orElseThrow(IllegalStateException::new);
+ messagesService.recommendMessage(anotherMid, recommender3.getUid());
assertThat(messagesService.getPopularCandidates().get(0), is(anotherMid));
messagesService.recommendMessage(anotherMid, serviceUser.getUid());
assertThat(messagesService.getPopularCandidates().isEmpty(), is(true));