From 80c5bfe42e12427ee79733a8d7368172aaf2b34d Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 24 Jun 2019 14:03:35 +0800 Subject: [PATCH] user fanslist and watchlist support new version watcher --- app/controllers/users_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 64e7aa86..d5f6ebfb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4178,7 +4178,8 @@ class UsersController < ApplicationController ###add by huang def user_watchlist - watch_query = User.watched_by(@user.id) + watch_query = User.joins('left join watchers on watchers.watchable_id = users.id and watchers.watchable_type in ("Principal", "User")') + .where('watchers.user_id = ?', @user.id) @user_watchlist_count = watch_query.size @user_watchlist = watch_query.order("#{Watcher.table_name}.id desc") @limit = 10 @@ -4191,7 +4192,8 @@ class UsersController < ApplicationController ###add by huang def user_fanslist - fan_query = @user.watcher_users + fan_query = User.joins('left join watchers on watchers.user_id = users.id and watchers.watchable_type in ("Principal", "User")') + .where('watchers.watchable_id = ?', @user.id) @user_fanlist_count = fan_query.size @user_fanlist = fan_query.order("#{Watcher.table_name}.id desc")