From 75a631d48bc3e3fea8d35cddbe0e2c639c252796 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 12 Feb 2023 05:10:54 +0300 Subject: Drop `users_subscr` table --- src/main/java/com/juick/service/UserServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java index 57fcd399..932be19c 100644 --- a/src/main/java/com/juick/service/UserServiceImpl.java +++ b/src/main/java/com/juick/service/UserServiceImpl.java @@ -439,11 +439,11 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { @Transactional(readOnly = true) @Override public List getUserReadLeastPopular(final int uid, final int cnt) { - return getJdbcTemplate().query( - "SELECT users.id,users.nick FROM (subscr_users " + - "INNER JOIN users_subscr ON (subscr_users.suser_id=? " + - "AND subscr_users.user_id=users_subscr.user_id)) INNER JOIN users " + - "ON subscr_users.user_id=users.id ORDER BY cnt " + limit(cnt), + return getJdbcTemplate().query(""" + SELECT users.id,users.nick, (select count(*) from subscr_users where user_id=users.id) cnt + FROM subscr_users INNER JOIN users + ON subscr_users.user_id=users.id WHERE subscr_users.suser_id=? ORDER by cnt + """ + limit(cnt), (rs, num) -> { User u = new User(); u.setUid(rs.getInt(1)); -- cgit v1.2.3