about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-14 01:19:25 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-14 01:19:25 +0100
commitcea28e0c1d91489756491f24a3e1376188d2bbf8 (patch)
tree23a5b4bc4cec0f7144682203d64b589ff3f029a9 /app/controllers
parentf8f15e5697c1f6e31cd2ee8e1ac5f654454c7dfe (diff)
Fix wrong link header on followers API, wrong link in tabs component, order
account results
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/v1/accounts_controller.rb10
-rw-r--r--app/controllers/api/v1/statuses_controller.rb6
2 files changed, 10 insertions, 6 deletions
diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb
index 9573326ef..88af41bf8 100644
--- a/app/controllers/api/v1/accounts_controller.rb
+++ b/app/controllers/api/v1/accounts_controller.rb
@@ -16,7 +16,8 @@ class Api::V1::AccountsController < ApiController
 
   def following
     results   = Follow.where(account: @account).paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])
-    @accounts = Account.where(id: results.map(&:target_account_id)).with_counters.to_a
+    accounts  = Account.where(id: results.map(&:target_account_id)).with_counters.map { |a| [a.id, a] }.to_h
+    @accounts = results.map { |f| accounts[f.target_account_id] }
 
     next_path = following_api_v1_account_url(max_id: results.last.id)    if results.size == DEFAULT_ACCOUNTS_LIMIT
     prev_path = following_api_v1_account_url(since_id: results.first.id) if results.size > 0
@@ -28,10 +29,11 @@ class Api::V1::AccountsController < ApiController
 
   def followers
     results   = Follow.where(target_account: @account).paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])
-    @accounts = Account.where(id: results.map(&:account_id)).with_counters.to_a
+    accounts  = Account.where(id: results.map(&:account_id)).with_counters.map { |a| [a.id, a] }.to_h
+    @accounts = results.map { |f| accounts[f.account_id] }
 
-    next_path = following_api_v1_account_url(max_id: results.last.id)    if results.size == DEFAULT_ACCOUNTS_LIMIT
-    prev_path = following_api_v1_account_url(since_id: results.first.id) if results.size > 0
+    next_path = followers_api_v1_account_url(max_id: results.last.id)    if results.size == DEFAULT_ACCOUNTS_LIMIT
+    prev_path = followers_api_v1_account_url(since_id: results.first.id) if results.size > 0
 
     set_pagination_headers(next_path, prev_path)
 
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb
index 3c86cae00..f5dbbd013 100644
--- a/app/controllers/api/v1/statuses_controller.rb
+++ b/app/controllers/api/v1/statuses_controller.rb
@@ -16,7 +16,8 @@ class Api::V1::StatusesController < ApiController
 
   def reblogged_by
     results   = @status.reblogs.paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])
-    @accounts = Account.where(id: results.map(&:account_id)).with_counters.to_a
+    accounts  = Account.where(id: results.map(&:account_id)).with_counters.map { |a| [a.id, a] }.to_h
+    @accounts = results.map { |r| accounts[r.account_id] }
 
     next_path = reblogged_by_api_v1_status_url(max_id: results.last.id)    if results.size == DEFAULT_ACCOUNTS_LIMIT
     prev_path = reblogged_by_api_v1_status_url(since_id: results.first.id) if results.size > 0
@@ -28,7 +29,8 @@ class Api::V1::StatusesController < ApiController
 
   def favourited_by
     results   = @status.favourites.paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])
-    @accounts = Account.where(id: results.map(&:account_id)).with_counters.to_a
+    accounts  = Account.where(id: results.map(&:account_id)).with_counters.map { |a| [a.id, a] }.to_h
+    @accounts = results.map { |f| accounts[f.account_id] }
 
     next_path = favourited_by_api_v1_status_url(max_id: results.last.id)    if results.size == DEFAULT_ACCOUNTS_LIMIT
     prev_path = favourited_by_api_v1_status_url(since_id: results.first.id) if results.size > 0