diff options
author | alpaca-tc <alpaca-tc@alpaca.tc> | 2017-05-06 11:03:07 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-06 04:03:07 +0200 |
commit | ddc34feb5875fd247fc7331b7710406d6de4a143 (patch) | |
tree | 5a1b654b9974ac1a5549bed6faa7abe8d92c4dfc | |
parent | 3f5b994ff0674fa8e0e5676ca22f0c347f9d7712 (diff) |
Optimize follower_accounts and following_accounts (#2820)
-rw-r--r-- | app/controllers/follower_accounts_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/following_accounts_controller.rb | 2 | ||||
-rw-r--r-- | app/views/accounts/_follow_grid.html.haml | 2 | ||||
-rw-r--r-- | app/views/follower_accounts/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/following_accounts/index.html.haml | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb index 25c7a893a..d56bd2a4d 100644 --- a/app/controllers/follower_accounts_controller.rb +++ b/app/controllers/follower_accounts_controller.rb @@ -4,6 +4,6 @@ class FollowerAccountsController < ApplicationController include AccountControllerConcern def index - @accounts = @account.followers.page(params[:page]).per(FOLLOW_PER_PAGE) + @follows = Follow.where(target_account: @account).order(id: :desc).page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account) end end diff --git a/app/controllers/following_accounts_controller.rb b/app/controllers/following_accounts_controller.rb index 0a8062680..925647864 100644 --- a/app/controllers/following_accounts_controller.rb +++ b/app/controllers/following_accounts_controller.rb @@ -4,6 +4,6 @@ class FollowingAccountsController < ApplicationController include AccountControllerConcern def index - @accounts = @account.following.page(params[:page]).per(FOLLOW_PER_PAGE) + @follows = Follow.where(account: @account).order(id: :desc).page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account) end end diff --git a/app/views/accounts/_follow_grid.html.haml b/app/views/accounts/_follow_grid.html.haml index 322a0ebf4..10fbfa546 100644 --- a/app/views/accounts/_follow_grid.html.haml +++ b/app/views/accounts/_follow_grid.html.haml @@ -4,4 +4,4 @@ - else = render partial: 'accounts/grid_card', collection: accounts, as: :account, cached: true -= paginate accounts += paginate follows diff --git a/app/views/follower_accounts/index.html.haml b/app/views/follower_accounts/index.html.haml index ee62c79eb..89c7f3a29 100644 --- a/app/views/follower_accounts/index.html.haml +++ b/app/views/follower_accounts/index.html.haml @@ -6,4 +6,4 @@ = render 'accounts/header', account: @account -= render 'accounts/follow_grid', accounts: @accounts += render 'accounts/follow_grid', follows: @follows, accounts: @follows.map(&:account) diff --git a/app/views/following_accounts/index.html.haml b/app/views/following_accounts/index.html.haml index 68a0ef838..6f0de7590 100644 --- a/app/views/following_accounts/index.html.haml +++ b/app/views/following_accounts/index.html.haml @@ -6,4 +6,4 @@ = render 'accounts/header', account: @account -= render 'accounts/follow_grid', accounts: @accounts += render 'accounts/follow_grid', follows: @follows, accounts: @follows.map(&:target_account) |