Move includes into `cursored_friends`/`cursored_followers`
This commit is contained in:
parent
7e57735b88
commit
0da070c5ff
|
@ -84,7 +84,7 @@ class UserController < ApplicationController
|
||||||
|
|
||||||
def followers
|
def followers
|
||||||
@title = 'Followers'
|
@title = 'Followers'
|
||||||
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first!
|
||||||
@users = @user.cursored_followers(last_id: params[:last_id])
|
@users = @user.cursored_followers(last_id: params[:last_id])
|
||||||
@users_last_id = @users.map(&:id).min
|
@users_last_id = @users.map(&:id).min
|
||||||
@more_data_available = !@user.cursored_followers(last_id: @users_last_id, size: 1).count.zero?
|
@more_data_available = !@user.cursored_followers(last_id: @users_last_id, size: 1).count.zero?
|
||||||
|
@ -98,8 +98,8 @@ class UserController < ApplicationController
|
||||||
|
|
||||||
def friends
|
def friends
|
||||||
@title = 'Following'
|
@title = 'Following'
|
||||||
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first!
|
||||||
@users = @user.cursored_friends(last_id: params[:last_id]).includes(:profile)
|
@users = @user.cursored_friends(last_id: params[:last_id])
|
||||||
@users_last_id = @users.map(&:id).min
|
@users_last_id = @users.map(&:id).min
|
||||||
@more_data_available = !@user.cursored_friends(last_id: @users_last_id, size: 1).count.zero?
|
@more_data_available = !@user.cursored_friends(last_id: @users_last_id, size: 1).count.zero?
|
||||||
@type = :friend
|
@type = :friend
|
||||||
|
@ -112,7 +112,7 @@ class UserController < ApplicationController
|
||||||
|
|
||||||
def questions
|
def questions
|
||||||
@title = 'Questions'
|
@title = 'Questions'
|
||||||
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first!
|
||||||
@questions = @user.cursored_questions(author_is_anonymous: false, last_id: params[:last_id])
|
@questions = @user.cursored_questions(author_is_anonymous: false, last_id: params[:last_id])
|
||||||
@questions_last_id = @questions.map(&:id).min
|
@questions_last_id = @questions.map(&:id).min
|
||||||
@more_data_available = !@user.cursored_questions(author_is_anonymous: false, last_id: @questions_last_id, size: 1).count.zero?
|
@more_data_available = !@user.cursored_questions(author_is_anonymous: false, last_id: @questions_last_id, size: 1).count.zero?
|
||||||
|
|
|
@ -7,10 +7,10 @@ module User::RelationshipMethods
|
||||||
define_cursor_paginator :cursored_followers, :ordered_followers
|
define_cursor_paginator :cursored_followers, :ordered_followers
|
||||||
|
|
||||||
def ordered_friends
|
def ordered_friends
|
||||||
friends.reverse_order
|
friends.reverse_order.includes(:profile)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ordered_followers
|
def ordered_followers
|
||||||
followers.reverse_order
|
followers.reverse_order.includes(:profile)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue