aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/MessagesServiceImpl.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-10-21 22:52:14 +0300
committerGravatar Vitaly Takmazov2021-10-21 22:52:14 +0300
commitc6972c05dcee19afb5725767f755a56f5162aee2 (patch)
tree64b8f3588e97d8e1141fc17646e99a11f57abe46 /src/main/java/com/juick/service/MessagesServiceImpl.java
parentcfb6c1894d8223eac62d03eeececa7baf192aced (diff)
Make popular feed equal to service user recommendations feed to have correct RSS feeds
Diffstat (limited to 'src/main/java/com/juick/service/MessagesServiceImpl.java')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java52
1 files changed, 8 insertions, 44 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index c2e5d15d..0625716a 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -623,20 +623,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional(readOnly = true)
@Override
- public List<Integer> getPopular(final int visitorUid, final int before) {
- SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("vid", visitorUid)
- .addValue("before", before);
-
- return getNamedParameterJdbcTemplate().queryForList("SELECT m.message_id FROM messages m WHERE m.privacy > 0 "
- + (before > 0 ? " AND m.message_id < :before " : StringUtils.EMPTY)
- + " AND m.popular > 0 AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = m.user_id) "
- + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN "
- + "(SELECT tag_id FROM messages_tags WHERE message_id = m.message_id) and :vid = bt.user_id)"
- + " ORDER BY m.message_id DESC LIMIT 20", sqlParameterSource, Integer.class);
- }
-
- @Transactional(readOnly = true)
- @Override
public List<Integer> getPhotos(final int visitorUid, final int before) {
SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("vid", visitorUid)
.addValue("before", before);
@@ -705,9 +691,11 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional(readOnly = true)
@Override
- public List<Integer> getUserBlogWithRecommendations(final int uid, final int privacy, final int before) {
- SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("uid", uid)
- .addValue("privacy", privacy).addValue("before", before);
+ public List<Integer> getUserBlogWithRecommendations(final User user, final User visitor, final int privacy, final int before) {
+ SqlParameterSource sqlParameterSource = new MapSqlParameterSource()
+ .addValue("uid", user.getUid())
+ .addValue("vid", visitor.getUid())
+ .addValue("privacy", privacy).addValue("before", before);
return getNamedParameterJdbcTemplate()
.queryForList("SELECT message_id FROM " + "(SELECT message_id FROM favorites " + " INNER JOIN users"
@@ -716,6 +704,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ " ORDER BY message_id DESC LIMIT 20) as r" + " UNION ALL " + "SELECT message_id FROM "
+ "(SELECT message_id FROM messages" + " INNER JOIN users" + " ON messages.user_id = users.id"
+ " WHERE user_id = :uid AND users.banned = 0"
+ + " AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = messages.user_id) "
+ + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN "
+ + "(SELECT tag_id FROM messages_tags WHERE message_id = messages.message_id) and :vid = bt.user_id)"
+ (before > 0 ? " AND message_id < :before" : StringUtils.EMPTY)
+ " AND privacy >= :privacy ORDER BY message_id DESC LIMIT 20) as m "
+ "ORDER BY message_id DESC LIMIT 20", sqlParameterSource, Integer.class);
@@ -870,33 +861,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional
@Override
- public boolean setMessagePopular(final int mid, final int popular) {
- int ret;
- MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("mid", mid).addValue("popular",
- popular);
-
- switch (popular) {
- case -2:
- ret = getNamedParameterJdbcTemplate().update("UPDATE messages SET hidden = 1 WHERE message_id = :mid",
- sqlParameterSource);
- break;
- case -1:
- sqlParameterSource.addValue("popular", 0);
- default:
- ret = getNamedParameterJdbcTemplate()
- .update("UPDATE messages SET popular = :popular WHERE message_id = :mid", sqlParameterSource);
- break;
- }
-
- if (popular == -1)
- ret = getNamedParameterJdbcTemplate().update("INSERT INTO top_ignore_messages VALUES (:mid)",
- sqlParameterSource);
-
- return ret > 0;
- }
-
- @Transactional
- @Override
public boolean setMessagePrivacy(final int mid) {
return getJdbcTemplate().update("UPDATE messages SET privacy=1 WHERE message_id=?", mid) > 0;
}